In C++
A new fruit juice machine has been purchased for the cafeteria, and a program is needed to make the machine function properly. The machine dispenses apple juice, orange juice, mango lassi, and fruit punch in recyclable containers. In this programming example, we write a program for the fruit juice machine so that it can be put into operation.
The program should do the following:
Hint: A juice machine has two main components: a built-in cash register and several dispensers to hold and release the products
1] Add some drinks.
2] Have your dispenser track how much money has been deposited, and
only issue a drink when the required cents have been
deposited.
3] Also make sure to tell the user if they have a change coming
back from the machine.
Solved 1 Answer
See More Answers for FREE
Enhance your learning with StudyX
Receive support from our dedicated community users and experts
See up to 20 answers per week for free
Experience reliable customer service
here is the code for your requirement   go throgh the comments for better understanding!!!! #include<iostream> #include <stdlib.h> #include <string.h> #include <iomanip> using namespace std;   struct JuiceDispensor //class 1...from the question(used srtuct method for compiling purpose) { char name[20]; float price; unsigned quantity; }; struct MoneyRegister //calss 2 from the question(used struct method for compiling purpose) { int money; float change; int price; }   int main() { JuiceDispensor drink[5]; //Menu of the juice available   strcpy(drink[0].name,"Apple juice"); drink[0].price=75; drink[0].quantity=20; strcpy(drink[1].name,"Orange juice"); drink[1].price=75; drink[1].quantity=20; strcpy(drink[2].name,"Mango juice"); drink[2].price=75; drink[2].quantity=20; strcpy(drink[3].name,"Fruit punch"); drink[3].price=80; drink[3].quantity=20;   std::cout << std::fixed; std::cout << std::setprecision(4);    int choice = 1;   while(choice != 5) { cout<<"n 1) "<<drink[0].name<<"tt"<<drink[0].price<<"t("<<drink[0].quantity<<") remaining"; cout<<"n 2) "<<drink[1].name<<"tt"<<drink[1].price<<"t("<<drink[1].quantity<<") remaining"; cout<<"n 3) "<<drink[2].name<<"tt"<<drink[2].price<<"t("<<drink[2].quantity<<") remaining"; cout<<"n 4) "<<drink[3].name<<"tt"<<drink[3].price<<"t("<<drink[3].quantity<<") remaining"; cout<<"n 5) Leave the drink machine nn"; cout<<"n Choose one:"; cin>>choice;   if(choice >=1 && choice <=4) { if(drink[choice-1].quantity == 0) { cout<<"n No more " << drink[choice-1].name <<" Available .."; getchar(); getchar();continue; } }   if(choice == 5) cout<<"Thank for using it !!"; else if(choice <= 4) { float money; cout<<"n Enter any amount of money: "; cin>>money;   float price; if(choice>=1 && choice <=3) { price = 75; if((money < price)){ cout<<"n Enter sufficient amount "; getchar(); getchar(); continue; } } else if(choice ==4 || choice ==5) { price = 80; if((money < price)){ cout<<"n Enter sufficient amount "; getchar();getchar(); continue; } } cout<<"n you slected:"<<drink[choice-1].name; //After successsfull purchase of item cout<<"n Enjoy your beverage "; cout<<"nn Change calcualted : "<< money-price; cout<<"n You change, "<<money-price<<" just droped into the Change Dispenser."; drink[choice-1].quantity = drink[choice-1].quantity - 1;   cout<<"n There are "<< drink[choice-1].quantity <<" drinks of that type left";   getchar(); getchar();   } else { cout<<"n Warning : Invalid Choice "; }   }   return 0; } ...