C++ Write a program allows the restaurant owner input the number of different en
ID: 3835001 • Letter: C
Question
C++
Write a program allows the restaurant owner input the number of different entrees they wish to prepare for the week. The program will tell the owner exactly how much of each ingredient they will need to order. By using this program, they will be able to eliminate waste and order quickly and efficiently. The owner will have the option to edit the menu entrees and the ingredients. Each menu entree will be represented by a struct containing the amount of each ingredient required to make it. Choose a list of entrees and ingrediants. • The program must be written in a modularized / object oriented manner. • You MUST make effective use of data structures ( don't use a dynamic array or a vector when a simple static array will do the job).
Explanation / Answer
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
char choice='Y';
int order = 1;
int var=0;
string entrees[3];
int num1=0, num2=0, num3=0, num4=0, num5=0;
int num_customers;
int sentinel=0;
double UnitPrice1= 6.95, UnitPrice2= 5.75,UnitPrice3= 7.25;
double AmountofSale1=0, AmountofSale2=0, AmountofSale3=0;
double TotalAmount=0;
cout<<"Enter the new menu entrees ";
for(int i=0;i<3;i++)
{
cin>>entrees[i];
}
cout<<"___________________Menu________________ ";
for(int j=0;j<3;j++)
{
cout<<"_____"<<(j)<<" ";
cout<<entrees[j]<<" ";
cout<<"_____ ";
}
cout<<"_____"<<"99 "<< "RemoveItem ";
cout<<"_____"<<"-99 "<< "Exit ";
while (order != -99)
{
cout<<"From the list of food, what would you like: ";
cin>>order;
switch(order)
{
case 0:
cout<<"How many "<<entrees[0]<<" would you like to order: ";
cin>>num1;
AmountofSale1 = UnitPrice1 * num1;
TotalAmount=TotalAmount+AmountofSale1;
break;
case 1:
cout<<"How many "<<entrees[1]<<" would you like to order: ";
cin>>num2;
AmountofSale2= UnitPrice2 * num2;
TotalAmount=TotalAmount+AmountofSale2;
break;
case 2:
cout<<"How many "<<entrees[2]<<" would you like to order: ";
cin>>num3;
AmountofSale3= UnitPrice3 * num3;
TotalAmount=TotalAmount+AmountofSale3;
break;
case 99:
cout<<"Which entrees do you want to delete ";
cin>>var;
cout<<"___________________Menu________________ ";
for(int var;var<3;var++)
{
entrees[var] = entrees[var + 1];
}
cout<<entrees[var]<<" Is removed from the entrees ";
main();
break;
default: cout<<"Please choose a valid item from our list ";
}
}
cout<<" Successfully placed an order ";
cout<<"Total amount "<<TotalAmount;
system("PAUSE");
return 0;
}
Output:
Enter the new menu entrees
idly
sambar
vada
___________________Menu________________
_____0 idly _____
_____1 sambar _____
_____2 vada _____
_____99 RemoveItem
From the list of food, what would you like:
0
How many idly would you like to order:
1
From the list of food, what would you like:
2
How many vada would you like to order:
1
From the list of food, what would you like:
-99
Please choose a valid item from our list
Successfully placed an order
Total amount14.2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.