#include <iostream> #include <string> using namespace std; void breakfastMenu(); void baconAndEggs(); void cereal(); void pancakes(); void lunchMenu(); void PBandJ(); void cheeseburger(); void hotWings(); void dinnerMenu(); void salad(); void steak(); void fish(); void dessertMenu(); void chocolateCake(); void cobbler(); void applePie(); void iceCream(); bool finalOption(std::string); int calories=0; float cost=0; int main() { bool exit=true; cout<<"How many meals would you like?\n"; int j,i,k; cin>>i; for (k=0;k<i;k++) { cout<<"Which Meal?\n"<<"\t(1)Breakfast\n"; cout<<"\t(2)Lunch\n"<<"\t(3)Dinner\n"; cout<<"\t(4)Desert\n"<<"\t(0)Exit"; cin>>j; switch (j) { case (1): breakfastMenu(); break; case (2): lunchMenu(); break; case (3): dinnerMenu(); break; case (4): dessertMenu(); break; case (0): k=i; //breaks while loop break; default: cout<<"That is not a valid option."; k--; break; }; }; cout<<"Total Calories="<<calories<<"\n"; cout<<"Total Cost="<<cost<<"\n"; } void breakfastMenu() { bool exit=true; int i; cout<<"Which meal would you like to have?\n"<<"\t(1)Cereal\n"; cout<<"\t(2)Bacon and Eggs\n"<<"\t(3)Pancakes\n"; cout<<"\t(0)Exit"; cin>>i; switch (i) { case (1): cereal(); break; case (2): baconAndEggs(); break; case (3): pancakes(); break; case (0): //exits while loop break; default: cout<<"That is not a valid option.\n"; break; }; } void cereal() { cout<<"Cereal is 90 calories\n"<<"Cereal costs $3.00\n"; if (finalOption("cereal")) { calories=calories+90; cost=cost+3.00; } } void baconAndEggs() { cout<<"Bacon and Eggs are 200 calories\n"<<"Bacon and Eggs cost $7.00\n"; if (finalOption("Bacon and Eggs")) { calories=calories+200; cost=cost+7.00; } } void pancakes() { cout<<"Pancakes are 350 calories\n"<<"Pancakes cost $5.00\n"; if(finalOption("Pancakes")) { calories=calories+350; cost=cost+5.00; } } void lunchMenu() { bool exit=true; int i; cout<<"Which meal would you like to have?\n"; cout<<"\t(1)Peanut Butter and Jelly\n"<<"\t(2)Cheeseburger\n"; cout<<"\t(3)Hot Wings\n"<<"\t(0)Exit\n"; cin>>i; switch (i) { case (1): PBandJ(); break; case (2): cheeseburger(); break; case (3): hotWings(); break; case (0): exit=false; break; default: cout<<"That is not a valid option. Please choose again"; k--; break; }; } void PBandJ() { cout<<"Peanut Butter and Jelly is 250 calories\n"; cout<<"Peanut Butter and Jelly costs $3.50\n"; if(finalOption("Peanut Butter and Jelly")) { calories=calories+250; cost=cost+3.50; } } void cheeseburger() { cout<<"A cheeseburger is 450 calories\n"; cout<<"A cheeseburger is 8.50\n"; if(finalOption("a cheeseburger")) { cost=cost+8.50; calories=calories+450; } } void hotWings() { cout<<"Hot Wings are 300 calories\n"; cout<<"Hot Wings cost $5.00\n"; if(finalOption("Hot Wings")) { cost=cost+5.00; calories=calories+300; } } void dinnerMenu() { bool exit=false; int i; cout<<"Which meal would you like?\n"<<"\t(1)Cheeseburger\n"; cout<<"\t(2)Salad\n"<<"\t(3)Steak\n"; cout<<"\t(4)Fish\n"<<"\t(0)Exit\n"; cin>>i; switch (i) { case (1): cheeseburger(); break; case (2): salad(); break; case (3): steak(); break; case (4): fish(); break; case (0): exit=false; break; default: cout<<"That is not a viable option"; break; }; } void salad() { cout<<"A salad has 850 calories\n"; cout<<"A salad costs $6.50\n"; if(finalOption("a salad")) { calories=calories+850; cost=cost+6.50; } void steak() { cout<<"A steak has 450 calories\n"; cout<<"A steak costs $10.00\n"; if(finalOption("a steak")) { cost=cost+10.00; calories=calories+450; } } void fish() { cout<<"Fish has 350 calories\n"; cout<<"Fish costs $6.50\n"; if(finalOption("fish")) { cost=cost+6.50; calories=calories+350; } void dessertMenu() { int i; cout<<"Which dessert would you like?\n"<<"\t(1)Chocolate Cake\n"; cout<<"\t(2)Cobbler\n"<<"\t(3)Apple Pie\n"; cout<<"\t(4)Ice Cream\n"<<"\t(0)Exit\n"; cin>>i; switch (i) { case (1): chocolateCake(); break; case (2): cobbler(); break; case (3): applePie(); break; case (4): iceCream(); break; case (0): break; default: cout<<"That is not a viable option\n"; break; }; } void chocolateCake() { cout<<"A chocolate cake has 550 calories\n"; cout<<"A chocolate cake costs $4.50\n"; if(finalOption("a chocolate cake")) { cost=cost+4.00; calories=calories+550; } } void cobbler() { cout<<"Today's cobbler is peach\n"; cout<<"Cobbler has 450 calories\n"; cout<<"Cobbler costs $6.50\n"; if(finalOption("cobbler")) { cost=cost+6.50; calories=calroies+450; } } void applePie() { cout<<"Apple pie has 350 calories\n"; cout<<"Apple pie costs $4.50\n"; if(finalOption("apple pie")) { calories=calories+350; cost=cost+4.50; } void iceCream() { cout<<"Ice cream has 400 calories\n"; cout<<"Ice cream costs $3.50\n"; if(finalOption("ice cream")) { calories=calories+400; cost=cost+3.50; } } bool finalOption(string thatFood) { cout<<"Are you sure you would like "<<thatFood<<"?\n"; cout<<"(1)Yes\n"<<"(2)No\n"; int i; cin>>i; switch(i) { case (1): cout<<"Your "<<thatFood<<" has been ordered\n"; return true; break; case (2): cout<<"Your order for "<<thatFood<<" has been canceled\n"; return false; break; default: return false; break; }; } |
cout<<"Total Calories="<<calories<<"\n"; cout<<"Total Cost="<<cost<<"\n"; |