write cplus programs for exercises
Drink Machine Simulator
Create a class that simulates and manages a soft drink machine.Information on each drink
type should be stored in a structure that has data members to holdthe drink name, the
drink price, and the number of drinks of that type currently in themachine.
The class should have an array of ï¬ve of these structures,initialized with the following data.
Drink Name    Cost  Number inMachine
Cola     1.00  20
Root beer        1.00     20
Orange soda   1.00     20
Grape soda    1.50 20
Bottled water   1.50     20
The class should have two public member functions,displayChoices (which displays a
menu of drink names and prices) and buyDrink (which handles asale). The class should
also have at least two private member functions, inputMoney, whichis called by buyDrink
to accept, validate, and return (to buyDrink) the amount of moneyinput, and
dailyReport, which is called by the destructor to report how manyof each drink type
remain in the machine at the end of the day and how much money wascollected.
You may want to use additional functions to make the programmore modular.
The client program that uses the class should have a mainprocessing loop which calls the
displayChoices class member function and allows the patron toeither pick a drink or
quit the program. If the patron selects a drink, the buyDrink classmember function is
called to handle the actual sale. This function should be passedthe patron’s drink choice.
Here is what the buyDrink function should do:
• Call the inputMoney function, passing it the patron’s drinkchoice.
• If the patron no longer wishes to make the purchase, return allinput money.
• If the machine is out of the requested soda, display anappropriate “sold out†message and return all input money.
• If the machine has the soda and enough money was entered,complete the sale by updating the quantity on hand and moneycollected information, calculating any change due to be returned tothe patron, and delivering the soda.
This last action can be simulated by printing an appropriate“here is your beverage†message.
Input Validation: Only accept valid menu choices. Do not deliver abeverage if the
money inserted is less than the price of the selected drink.
For exact input
output messages and menu choices, please refer to the test casesfile below.
TEST CASE1:Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 1How much money has been inserted: $5Do you still want to make a purchase? (Y / N) : yHere is your Cola, and your change of $4.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 2How much money has been inserted: $6Do you still want to make a purchase? (Y / N) : yHere is your Root Beer, and your change of $5.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 3How much money has been inserted: $4Do you still want to make a purchase? (Y / N) : yHere is your Orange Soda, and your change of $3.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 4How much money has been inserted: $8Do you still want to make a purchase? (Y / N) : yHere is your Grape Soda, and your change of $6.50Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 5How much money has been inserted: $3Do you still want to make a purchase? (Y / N) : yHere is your Bottled Water, and your change of $1.50Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 6Thank you for shopping!Drink Machine Daily ReportCola : 19Root Beer : 19Orange Soda : 19Grape Soda : 19Bottled Water : 19Total amount collected : $6.00TEST CASE 2:Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 1How much money has been inserted: $1Do you still want to make a purchase? (Y / N) : yHere is your Cola, and your change of $0.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 2How much money has been inserted: $1Do you still want to make a purchase? (Y / N) : nDrink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 3How much money has been inserted: $4Do you still want to make a purchase? (Y / N) : yHere is your Orange Soda, and your change of $3.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 4How much money has been inserted: $1Not enough money, please enter $1.50 or more: $1Not enough money, please enter $1.50 or more: $2Do you still want to make a purchase? (Y / N) : tPlease enter Y or N: aPlease enter Y or N: bPlease enter Y or N: cPlease enter Y or N: dPlease enter Y or N: yHere is your Grape Soda, and your change of $0.50Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 9Please enter a valid choice (1 - 6): 1How much money has been inserted: $6Do you still want to make a purchase? (Y / N) : yHere is your Cola, and your change of $5.00Drink Machine Menu1. Cola : $1.002. Root Beer : $1.003. Orange Soda : $1.004. Grape Soda : $1.505. Bottled Water : $1.506. Quit Drink Machine Please make a selection : 6Thank you for shopping!Drink Machine Daily ReportCola : 18Root Beer : 20Orange Soda : 19Grape Soda : 19Bottled Water : 20Total amount collected : $4.50