Question

Assume that a restaurant offers the following breakfast items: Plain Egg $1.45 Bacon and Egg $2.45...

Assume that a restaurant offers the following breakfast items:

Plain Egg

$1.45

Bacon and Egg

$2.45

Muffin

$0.99

French Toast

$1.99

Fruit Basket

$2.49

Cereal

$0.69

Coffee

$0.50

Tea

$0.75

Write a program that stores the following data about each menu item in a structure called MenuItem:
• A description of the menu item
• The price of the menu item

• A count of the number of times the item has been ordered

The program should keep an array of these structures, one per menu item. When the

program runs, it should initialize the array using the data above, and 0 for the count.

The program should do the following:

  • Show the user the different breakfast items offered by the restaurant.

  • Allow the user to select multiple items from the menu (by number).

  • Calculate and print the bill (including sub-total, tax, and total)


    Note: the tax rate is 7%.

    Then it should ask the user to enter N to add a new order (repeat the steps above for a new order), and E to exit. Once the user selects E, the program should output the total amount of money taken in (the sum of all the orders) and then output the description and count of the item that was ordered the most frequently.

Your program must include three functions:

• one to display the menu (descriptions and prices only),
• one to take the order (it should return the sub-total for the order), and
• one to determine (and return) the index of the item with the highest count (if more

than one item has the maximum count, it must return the index of any one of them).

These functions should take an array of MenuItem (and perhaps other values) as arguments.

C++ Programming Language

Example of how output should look below

[1] Plain Egg        $ 1.45
[2] Bacon and Egg    $ 2.45
[3] Muffin           $ 0.99
[4] French Toast     $ 1.99
[5] Fruit Basket     $ 2.49
[6] Cereal           $ 0.69
[7] Coffee           $ 0.50
[8] Tea              $ 0.75
Input the item numbers for the order, 0 to quit
2 2 7 8 0
Subtotal...$   6.15
Tax........$   0.43
Total......$   6.58
Please enter 'N' to take a new order and 'E' to exit: N
[1] Plain Egg        $ 1.45
[2] Bacon and Egg    $ 2.45
[3] Muffin           $ 0.99
[4] French Toast     $ 1.99
[5] Fruit Basket     $ 2.49
[6] Cereal           $ 0.69
[7] Coffee           $ 0.50
[8] Tea              $ 0.75
Input the item numbers for the order, 0 to quit
1 3 6 7 7 0
Subtotal...$   4.13
Tax........$   0.29
Total......$   4.42
Please enter 'N' to take a new order and 'E' to exit: N
[1] Plain Egg        $ 1.45
[2] Bacon and Egg    $ 2.45
[3] Muffin           $ 0.99
[4] French Toast     $ 1.99
[5] Fruit Basket     $ 2.49
[6] Cereal           $ 0.69
[7] Coffee           $ 0.50
[8] Tea              $ 0.75
Input the item numbers for the order, 0 to quit
1 2 3 4 5 6 7 8 0
Subtotal...$  11.31
Tax........$   0.79
Total......$  12.10
Please enter 'N' to take a new order and 'E' to exit: E
End of Day: 
Total money taken in: $23.10
Item ordered most often: Coffee was ordered 4 times. 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <map>
#include <string>

using namespace std;

void getmenu() {
  
// map the menu with name and value
map<string, float> menuValues;
float taxRate = 0.07; // tax rate is 7% which will be in decimal as 0.07

// arrange menu names with order
string menuNames[8] = {"Plain Egg", "Bacon and Egg", "Muffin", "French Toast", "Fruit Basket", "Cereal","Coffee","Tea"};
  
// added each menu with its prices
menuValues["Plain Egg"] = 1.45;
menuValues["Bacon and Egg"] = 2.42;
menuValues["Muffin"] = 0.99;
menuValues["French Toast"] = 1.99;
menuValues["Fruit Basket"] = 2.49;
menuValues["Cereal"] = 0.69;
menuValues["Coffee"] = 0.50;
menuValues["Tea"] = 0.75;

// initialize subTotal to zero
float subTotal = 0;
// iterate loop to show menus with prices
for(int i = 0; i < 8; i++) {
string name = menuNames[i];
cout << "["<< (i + 1) <<"]"<< menuNames[i] << " $" << menuValues[name] << endl;
}

int arr[8];
cout << "Input the item numbers for the order, 0 to quit"<<endl;

// iterate the loop to ensure user input with either space or by next line
for(int i = 0; i < 7; i++) {
cin >> arr[i];
// if user entered zero break the input
if (arr[i] == 0) {
break;
}
string name = menuNames[i];
// calculate subTotal on user entered menu options
subTotal += menuValues[name];
}
// if subTotal zero no need to check or prints others
if (subTotal == 0) {
return;
}
//print respected value of selected menu with Tax
cout << "Subtotal........$" << subTotal <<endl;
cout << "Tax........$" << subTotal * taxRate <<endl;
cout << "Total........$" << (subTotal + subTotal * taxRate) <<endl;
  
// ask user for next action to be taken by either enter 'N' or 'E'
char str;
cout << "Please enter 'N' to take a new order and 'E' to exit: N" << endl;
cin >> str;
  
if (str == 'N') {


getmenu();
}
}

int main()
{
// call this function for first time execution
getmenu();

// quit if user entered other than 'N'
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Assume that a restaurant offers the following breakfast items: Plain Egg $1.45 Bacon and Egg $2.45...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Instructions Redo Exercise 4 so that the customer can select multiple items of a particular...

    C++ Instructions Redo Exercise 4 so that the customer can select multiple items of a particular type. A sample output in this case is: Welcome to Johnny's Resturant ----Today's Menu---- 1: Plain Egg $1.45 2: Bacon and Egg $2.45 3: Muffin $0.99 4: French Toast $1.99 5: Fruit Basket $2.49 6: Cereal $0.69 7: Coffee $0.50 8: Tea $0.75 You can make up to 8 different selections Do you want to make selection Y/y (Yes), N/n (No): Y Enter item...

  • c++ Write a C++ program using the struct keyword to help a local restaurant automate its...

    c++ Write a C++ program using the struct keyword to help a local restaurant automate its breakfast billing system The program should do the following: a. Show the customer the different breakfast items offered by the restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item) Menu Plain...

  • #include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem;...

    #include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem; double menuPrice; }; void getData(menuItemType menuList[]); void showMenu(menuItemType menuList[], int x); void printCheck(menuItemType menuList[], int menuOrder[], int x); int main() { const int menuItems = 8; menuItemType menuList[menuItems]; int menuOrder[menuItems] = {0}; int orderChoice = 0; bool ordering = true; int count = 0; getData(menuList); showMenu(menuList, menuItems); while(ordering) { cout << "Enter the number for the item you would\n" << "like to order, or...

  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

  • In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast...

    In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...

  • Worksheet 17-2: Diet Prescription—1800-Kcalorie, ADA Exchange Diet Select foods from the following menu that will fit...

    Worksheet 17-2: Diet Prescription—1800-Kcalorie, ADA Exchange Diet Select foods from the following menu that will fit within an order for an 1800-kcalorie diet, based on carbohydrate counting, distributing the carbohydrates evenly between all meals (based on 50% of kcalories from carbohydrate). Assume the foods listed will be served according to the serving sizes in the ADA exchange system (Appendix H). Breakfast Fruit Selection:         Banana, Fresh Fruit Cup, or Applesauce Juice Selection:         Orange, Prune, Cranberry, or Grape Juice Cereal Selection:       Oatmeal,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT