Question
Fix the code so it can output the correct information #include #include #include #include #include using namespace std; struct menu { double sushi = 4.99;
Fix the code so it can output the correct information
#include
#include
#include
#include
#include
using namespace std;
struct menu {
double sushi = 4.99;
double fries = 2.50;
double nuggets = 4.20;
double salad = 5.10;
double chicken = 4.34;
double pasta = 8.99;
double brownie = 6.30;
double ice_cream = 2.00;
double pizza = 5.25;
double pie = 2.30;
};
vector get_choices(){
vector choices;
cout"enter>
string s;
cin>>s;
while(s!="-1"){
transform(s.begin(),s.end(),s.begin(),::tolower);
choices.push_back(s);
cin>>s;
}
return choices;
}
int main(){
menu items;
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
vector order=get_choices();
double total_bill=0;
for(auto x:order){
if(x=="sushi") total_bill+=items.sushi;
if(x=="fries") total_bill+=items.fries;
if(x=="six nuggets") total_bill+=items.nuggets;
if(x=="small salad") total_bill+=items.salad;
if(x=="two pieces of chicken") total_bill+=items.chicken;
if(x=="pasta with meatballs") total_bill+=items.pasta;
if(x=="brownie") total_bill+=items.brownie;
if(x=="ice cream in a cup") total_bill+=items.ice_cream;
if(x=="pizza") total_bill+=items.pizza;
if(x=="apple pie") total_bill+=items.pie;
}
string disc;
cout"tell>
cin>>disc;
transform(disc.begin(),disc.end(),disc.begin(),::tolower);
if(disc=="senior citizen") total_bill*=0.95;
if(disc=="preferred member") total_bill*=0.92;
if(disc=="educator") total_bill*=0.975;
if(disc=="veteran") total_bill*=0.96;
//adding tax on discounted prices
total_bill+=total_bill*0.089;
cout"your>
cout">
double payment;
cin>>payment;
if(total_bill==payment){
cout"no>
}
else if(payment
cout"insufficient>">
}
else{
cout"your>
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started