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

Write a program that simulates a soft drink machine. Theprogram should use a str

ID: 3618497 • Letter: W

Question

Write a program that simulates a soft drink machine. Theprogram should use a structure that stores the followingdata:

Drink name

Drink cost

Number of drinks in machine

The program should create an array of five structures. Theelements should be initialized with the following data:

DrinkName                                       Cost                                      Number in Machine

Cola                                                      .75                                         20

RootBeer                                           .75                                         20

LemonLime                                      .75                                         20

GrapeSoda                                       .80                                         20

CreamSoda                                       .80                                         20

Each time the program runs, it should enter a loop thatperforms the following steps: a list of drinks is displayed on thescreen. The user should be allowed to either quit the program orpick a drink. If the user selects a drink, he or she will nextenter the amount of money that is to be inserted into the drinkmachine. The program should display the amount of change that wouldbe returned and subtract 1 form the number of that drink left inthe machine. If the user selects a drink that has sold out, amessage should be displayed. The loop then repeats. When the userchooses to quit the program it should display the total amount ofmoney the machine earned.

Input validation: When the user enters an amount of money,do not accept negative values, or values greater than$1.00.

Explanation / Answer

please rate - thanks #include #include using namespace std; struct Machine { string name; double cost; int num; }; void init(Machine&,string , double, int); int menu(Machine[]); void payment(double); int main() {Machine drink[5]; int choice; double made=0; init(drink[0],"Cola",.75,20); init(drink[1],"Root Beer",.75,20); init (drink[2],"Lemon Lime",.75,20); init (drink[3],"Grade Soda",.80,20); init (drink[4],"Cream Soda",.80,20); choice=menu(drink); while(choice!=5)    {    payment(drink[choice].cost);    made+=drink[choice].cost;    drink[choice].num--;    choice=menu(drink); } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote