Write a program that simulates a soft drink machine.The programshould use a stru
ID: 3618477 • Letter: W
Question
Write a program that simulates a soft drink machine.The programshould use a structure that stores the following data:Drink Name
Drink Cost
Number of Drinks in MAchine
The program should create an array of five structures. the elementsahould be initialized with the following data:
Drink Name
cost Number in Machine
Cola .75 20 Root Beer
.75
20
Lemon-Lime
.75
20
Grape Soda
.80
20
Cream Soda
.80
20
Each time the program runs, it should enter a loop thatperforms the following steps: A list of drinks is displayed on thescree. 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 dispaly the amount of change that wouldbe returned and substract one from page number of that drink leftin the machine. if the user selects a drink that has sold out, ameggage should be displayed. the loop then repeats. whne the userchoose to quit the program it should display the total amountof money the machine earned.
Drink Name
cost Number in Machine
Cola .75 20 Root Beer
.75
20
Lemon-Lime
.75
20
Grape Soda
.80
20
Cream Soda
.80
20
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); } coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.