Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 5 (100 Points) 1. (Upload as Source File) Lemonade Stand Simulator Write a p

ID: 2248353 • Letter: L

Question

Lab 5 (100 Points) 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. . On start up the program shall assume the inventory of the store is initialized to the following. ITEM LEMONS SUGAR MONEY BEVERAGES SOLD 0 INITIAL AMOUNT COST $o.50 $2.62 per 5 Pound Bag N/A +$2.50 0 $10.00 Your program shall prompt the user to choose an action. The menu shall look like the one shown below Il. elect one of the follouing Purchase lenons Purchase Sugar B: Sel1 Beverages Display Inventory Exit Selection: 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. 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 ($0.50) of the lemons purchased i. 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. . 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

Explanation / Answer

C++ , Visual Studio Program :

Lemonade stand simulator:

//include all header files needed for the programusing namespace std ;

# include <iostream>

# include <iomanip>

void main()

{

// first we need to assume the inventory of the store is initialised to the following values given in the table.

double Lemon_cost = 0.5;

double sugar_cost = 2.62;

double bev_cost = 2.5;

int no_lemons;               // both no_lemon and no_sugar variables are declared as int to accept whole nos

int no_sugar;

int no_bev;

double money = 10.0;

char Menu;

cout << " select one of the following " ;

cout << " L:Purchase Lemon" ;

cout << " S:Purchase sugar" ;

cout << " B:Sell Beverages" ;

cout << " I.Display Inventory" ;

cout << " E:Exit";

cout << " Selection:";

cin >> menu;

switch(menu)

{

case(L) :

lemon_buy();               // when selection is L go to lemon_buy() function

break;

case(S):

sugar_buy();                       // when selection is S go to sugar_buy() function

break;

case(B):

sell_beverage();             // when selection is B go to sell_beverage() function

break;

case(I):

cout<< " money remaining : " money ; // assuming to display only the remaining balance money

break;

case (E):         // when selection is E then exit the main function

exit(0);

break;

}      

void lemon_buy()

{

cout << " enter number of lemons to buy :"

cin >> no_lemon;

money = money - ( no_lemons * lemon_cost );          // buy reduces the balance money

}

void sugar_buy()

{

cout << " enter number of 5 pound sugar bag to buy :"

cin >> no_sugar;

money = money - ( no_sugar * sugar_cost );           // buy reduces the money balance

}

void sell_beverage()

{

cout << " enter number of beverages to sell :"

cin >> no_bev;

money = money + ( no_bev * bev_cost );          // since sell adds the money balace so add it to money

}

}