Question: create a program that aid the patrons in the Monty Python's Spam skit (https://www.youtube.com/watch?v=anwy2MPT5RE) in choosing their breakfast. When the program starts it should display

create a program that aid the patrons in the Monty Python's Spam skit (https://www.youtube.com/watch?v=anwy2MPT5RE) in choosing their breakfast.

When the program starts it should display a welcome message and then load the menu data from a file named "breakfast.dat". Below is the data found in file breakfast.dat

Spam and eggs% 1.99 Egg, bacon and spam% 2.99 Egg, bacon, sausage and spam% 3.99 Spam, bacon, sausage and spam% 4.99 Spam, egg, spam, spam, bacon and spam% 5.99 Spam, sausage, spam, bacon, spam, tomato and spam% 6.99 Spam, spam, spam, egg and spam% 6.99 Spam, spam, spam, spam, baked beans and spam% 7.99 Spam% 0.50 Coffee% 0.25

In the file the data is delimited by percent signs (%) and is guaranteed to contain exactly 10 breakfast items so you may create an arrays of 10 to hold the data in the file if you chose that route. I personally would use C++ vector Please inspect the file to determine how to best parse the menu items and prices. Note: At this point in your studies I would not recommend that you attempt to define your own data type (C++ struct or class. instead I recommend using parallel arrays/vectors (one container for the menu items and one for the prices).

After you load the data into either arrays or vectors pretty print it to the screen as is depicted in the image below. Please use the appropriate stream manipulators.

Next your program should loop endlessly, getting the user's choice (menu item number) and indicating that it was successfully recorded. I think the function "isdigit()" would be helpful at this point. If the user is finished entering all of the orders they can press "x" to exit the loop and tally the order (actually any character other than a digit should exit the loop). To keep track of the menu items the user is requesting I recommend another container to store their selections. Since it is not know in advance how many items they will order it is probably easiest to store their entries in a vector since it is trivial to add unlimited elements (not so in arrays).

To tally the items I would recommend a "for loop" that iterates over the selections container and uses the user's selections as an index into the menu item and prices container. e.g.

Finally the program should again iterate over the user selections, pretty printing her selections and the total of the order (no tax).

Below is a screen shot of the working program. Please replicate the sample completely.create a program that aid the patrons in the Monty Python's Spam

Not sure if this helps but this is some code I've started that is wrong.

#include "stdafx.h" #include #include #include #include #include #include using namespace std; int main() { //open file ifstream infile("breakfast.dat"); const int MENU_SIZE = 10; vector Foodmenu(MENU_SIZE); const int MENU_SIZE2 = 10; vector Pricemenu(MENU_SIZE2); int userChoice =0; string menuItem1; string menuItem2; string menuItem3; string menuItem4; string menuItem5; string menuItem6; string menuItem7; string menuItem8; string menuItem9; string menuItem10; double price1 = 0.00; double price2 = 0.00; double price3 = 0.00; double price4 = 0.00; double price5 = 0.00; double price6 = 0.00; double price7 = 0.00; double price8 = 0.00; double price9 = 0.00; double price10 = 0.00; //lazy way of doing file opening, couldnt figure out any other way... getline(infile, menuItem1, '%'); infile >> price1; getline(infile, menuItem2 , '%'); infile >> price2; getline(infile, menuItem3, '%'); infile >> price3; getline(infile, menuItem4, '%'); infile >> price4; getline(infile, menuItem5, '%'); infile >> price5; getline(infile, menuItem6, '%'); infile >> price6; getline(infile, menuItem7, '%'); infile >> price7; getline(infile, menuItem8, '%'); infile >> price8; getline(infile, menuItem9, '%'); infile >> price9; getline(infile, menuItem10, '%'); infile >> price10; menuItem2.erase(std::remove(menuItem2.begin(), menuItem2.end(), ' '), menuItem2.end()); menuItem3.erase(std::remove(menuItem3.begin(), menuItem3.end(), ' '), menuItem3.end()); menuItem4.erase(std::remove(menuItem4.begin(), menuItem4.end(), ' '), menuItem4.end()); menuItem5.erase(std::remove(menuItem5.begin(), menuItem5.end(), ' '), menuItem5.end()); menuItem6.erase(std::remove(menuItem6.begin(), menuItem6.end(), ' '), menuItem6.end()); menuItem7.erase(std::remove(menuItem7.begin(), menuItem7.end(), ' '), menuItem7.end()); menuItem8.erase(std::remove(menuItem8.begin(), menuItem8.end(), ' '), menuItem8.end()); menuItem9.erase(std::remove(menuItem9.begin(), menuItem9.end(), ' '), menuItem9.end()); menuItem10.erase(std::remove(menuItem10.begin(), menuItem10.end(), ' '), menuItem10.end()); //lazy way of setting information from file to vector Foodmenu.at(0) = menuItem1; Foodmenu.at(1) = menuItem2; Foodmenu.at(2) = menuItem3; Foodmenu.at(3) = menuItem4; Foodmenu.at(4) = menuItem5; Foodmenu.at(5) = menuItem6; Foodmenu.at(6) = menuItem7; Foodmenu.at(7) = menuItem8; Foodmenu.at(8) = menuItem9; Foodmenu.at(9) = menuItem10; Pricemenu.at(0) = price1; Pricemenu.at(1) = price2; Pricemenu.at(2) = price3; Pricemenu.at(3) = price4; Pricemenu.at(4) = price5; Pricemenu.at(5) = price6; Pricemenu.at(6) = price7; Pricemenu.at(7) = price8; Pricemenu.at(8) = price9; Pricemenu.at(9) = price10; //output start cout > userChoice; cout

Welocome to the Viking s Cafe Today's menu 1 Egg, bacon and spam................................-$2.99 3 :Spam, bacon, sausage and spam. .. . -$4.99 5 : Spam, sausage, spam, bacon, spam, tomato and spam. . .$6.99 7: Spam, spam, spam, spam, baked beans and spam. . -$7.99 Please enter the number of your selection or 'x to complete it. 6 Got it. 123 Got it Got it Got it. Got it. Tallying your order.. . No. : Spam and eggs . $1.99 Press any key to continu e

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!