..ITFW 4:26 PM Lab 5 1. (Upload as Source File) Lemonade Stand Simulator Write a
ID: 3167802 • Letter: #
Question
..ITFW 4:26 PM Lab 5 1. (Upload as Source File) Lemonade Stand Simulator Write a program to simulate the operations of a Lemonade Stand. Your program shall track the inventory of the lemons, sugar, and number of beverages sold as well as the amount of money in the account. While water is a vital component of making lemonade, it will be considered free since it is supplied by the parents. I. On start up the program shall assume the inventory of the store is initialized to the following. l Amount Cost 50.50 Sugar Money $2.62 per S Pound Bag N/A 52.50 ieverages Solds 10 II. Your program shall prompt the user to choose an action. The menu shall look like the one shown below a. If the action purchase lemons is selected, the program shall prompt the user to enter the number of lemons they wish to purchase. Lemons must be purchased whole, i.e. half a lemon cannot be purchased. i. Upon the user entering the number of lemons, update the number of lemons in the inventory, decrease the funds in the account based on the quantity and price (S0.50) of the lemons purchased. b. If the action purchase sugar is selected, the program shall prompt the user to enter the number of bags of sugar they wish to purchase. Again, bags must be purchased whole. i. Upon the user entering the number of bags of sugar, update the number of pounds of sugar in the inventory, decrease the funds in the account based on the quantity and price (S2.62) of the sugar purchased. Remember that a bag of sugar is 5 pounds. c. If the action sell beverages is selected the progranm shall prompt the user to enter the number of beverages sold. The number of beverages sold must be a whole number.Explanation / Answer
This works in matlab
lem_cant=0; lem_cost = 0.5;
sug_cant=0; sug_cost = 2.62; %bag of 5 pounds
money = 10; bev_sold=0;
while(true)
prompt = '1.- Purchase Lemons 2.- Purchase Sugar 3.- Sell Beverages 4.- Display Inventory 5.- Exit ';
x = input(prompt);
if x==1
prompt1='Enter the number of lemons wished to purchase :';
x1=input(prompt1);
if floor(x1)==x1
lem_cant=x1;
money=money-lem_cost*x1;
else
display('Number of lemons must be integer.');
end
elseif x==2
prompt2='Enter the number of bags of sugar wished to purchase :';
x2=input(prompt2);
if floor(x2)==x2
sug_cant=x1*5; %in pounds
money=money-sug_cost*x2;
else
display('Number of bags of sugar must be integer.');
end
elseif x==3
prompt3='Number of beverages sold';
x3=input(prompt3);
if floor(x3)==x3
lem_cant = lem_cant -3*x3;
sug_cant=sug_cant - 0.1*x3;
bev_sold=bev_sold + x3;
money=money + 2.5*x3;
else
display('Number of Beverages sold must be integer.');
end
elseif x==4
display(strcat('Current account :',num2str(money)));
display(strcat('Number of beverages sold :',num2str(bev_sold)))
display(strcat('Number of lemons in inventory :',num2str(lem_cant)))
display(strcat('Pounds of sugar in inventory :',num2str(sug_cant)))
elseif x==5
break;
else display('Wrong Selection')
end
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.