Question: Soda Machine simulator Write a program that simulates a soda machine. Implement this program in a file called soda.cpp . The program should work as
Soda Machine simulator
Write a program that simulates a soda machine. Implement this program in a file called soda.cpp The program should work as follows:
a The program should define a structure named Soda that contains the following attributes:
i Soda name
ii Soda cost
iii. Quantity available
b The program should initialize an array of five Soda structures with the following data in order:
tableSoda name,Cost,QuantityCola$Root Beer,$Orange Soda,$Seltzer Water,$Ginger Ale,$
c Before receiving user input, the program should display a menu detailing the available drinks numbered their costs in dollar format and quantity in a leftaligned fashion.
d The user should be able to select a drink or quit
i If the user enters an invalid menu selection, an appropriate error message should be displayed and they should be reprompted for another selection.
ii If the user selects a drink that is out of stock, an outofstock message should be displayed and they should be reprompted for another selection.
e After selecting a drink, the user should be able to input the amount of money they want to insert to pay. This machine only accepts nonzero values less than or equal to $
i If the user enters an invalid money amount, an appropriate error message should be displayed and they should be reprompted for a valid amount.
ii If the user enters a money amount less than the cost of the drink selected, an insufficientfunds message should be displayed and they should be reprompted for a valid amount.
iii. If the user enters a valid money amount, the quantity of the selected drink should be decremented and the leftover change should be displayed in dollar format.
f When the user quits, the program should display the total revenue earned by the soda machine in dollar format.
Example run underlined portions correspond to user input:
table Cola,$Qty: Root Beer,$Qty: Orange Soda,$Qty: Seltzer Water,$Qty: Ginger Ale,$Qty:
Select a soda or to quit:
Invalid selection, please try again:
Enter money to insert:
This machine only accepts $ or less
Enter money to insert:
Please enter a positive, nonzero dollar amount
Enter money to insert:
Change: $
table Cola,$Qty: Root Beer,$Qty: Orange Soda,$Qty: Seltzer Water,$Qty: Ginger Ale,$Qty:
Select a soda or to quit:
Enter money to insert:
Insufficient funds
Enter money to insert:
Change: $
table Cola,$Qty: Root Beer,$Qty: Orange Soda,$Qty: Seltzer Water,$Qty: Ginger Ale,$Qty:
Select a soda or to quit:
Seltzer Water is out of stock.
Select a soda or to quit:
Enter money to insert:
Change: $
table Cola,$Qty: Root Beer,$Qty: Orange Soda,$Qty: Seltzer Water,$Qty: Ginger Ale,$Oty:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
