Jason opened a coffee shop at the beach and sells coffee in

Jason opened a coffee shop at the beach and sells coffee in three sizes: small (9 oz), medium (12 oz), and large (15 oz). The cost of one small cup is $1.75, one medium cup is $1.90, and one large cup is $2.00. Write a menu-driven program that will make the coffee shop operational. Your program should allow the user to do the following:

Buy coffee in any size and in any number of cups.

At any time show the total number of cups of each size sold.

At any time show the total amount of coffee sold.

At any time show the total money made.

Solution

total_small_cups=9;
total_medium_cups=12;
total_large_cups=15;
total_amount=0;
while ((total_small_cups+total_medium_cups+total_large_cups)>0)
fprintf(\'\ \\t\\t\\t Available Items \ \\t\\t\\t Small cups: %d \ \\t\\t\\t Medium Cups: %d\ \\t\\t\\t Large Cups: %d\ \',total_small_cups,total_medium_cups,total_large_cups);
if total_small_cups<0
fprintf(\'All small cups are sold. Please select other cups.\ \');
else
prompt = \'Enter Number of small cup coffee : \';
small= input(prompt);
end
while small>total_small_cups
fprintf(\'There are only %d small cups avalabile.\ \',total_small_cups);
prompt = \'Enter Number of small cup coffee : \';
small= input(prompt);
end
total_small_cups=total_small_cups-small;

if total_medium_cups<0
fprintf(\'All medium cups are sold. Please select other cups.\ \');
else
prompt = \'Enter Number of medium cup coffee : \';
medium= input(prompt);
end
while medium>total_medium_cups
fprintf(\'There are only %d medium cups avalabile.\ \',total_medium_cups);
prompt = \'Enter Number of small cup coffee : \';
medium= input(prompt);
end
total_medium_cups=total_medium_cups-medium;

if total_large_cups<0
fprintf(\'All small cups are sold. Please select other cups.\ \');
else
prompt = \'Enter Number of small cup coffee : \';
large= input(prompt);
end
while large>total_large_cups
fprintf(\'There are only %d small cups avalabile.\ \',total_large_cups);
prompt = \'Enter Number of small cup coffee : \';
large= input(prompt);
end
total_large_cups=total_large_cups-large;

total_amount=total_amount+(1.75*small)+(1.90*medium)+(2.00*large);
fprintf(\'Total amount: %.4f\ \',total_amount\');
end
fprintf(\'All Items Sold Out\ \');
fprintf(\'Total amount: %.4f\ \',total_amount\');

Jason opened a coffee shop at the beach and sells coffee in three sizes: small (9 oz), medium (12 oz), and large (15 oz). The cost of one small cup is $1.75, on
Jason opened a coffee shop at the beach and sells coffee in three sizes: small (9 oz), medium (12 oz), and large (15 oz). The cost of one small cup is $1.75, on

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site