Sample Output (user input is in yellow) Welcome to the Programmers' Cafe ---Today's Menu-- 1: Egg (cooked to order) 2: Golden-Brown Pancake $1.99 $1.99 $2.99 $0.99 $1.20 $3.49 7: Steel-Cut Irish Oatmea1 $4.69 $1.50 $1.75 $1.75 3: French Toast 4: Muffin 5: Bagel w/ Spread 6: Fresh Fruit 8: Coffee 9: Pot of Assorted Tea 10: Hot Chocolate Do you want to place an order? (y/n): y Enter item number: 12 Enter item number between 1 and 10: 1 Enter item quantity: 12 Select another item? (y/n): y Enter item number: 3 Enter item quantity: 1 Select another iten? (y/n): y Enter item number: 7 Enter item quantity: 20 Select another item? (y/n): y Enter item number: 10 Enter item quantity: 2 Select another item? (y/n): n Thank you for eating at The Progranners' Cafe Receipt Qty Amount Egg (cooked to order) French Toast $ 23.88 1 $ 2.99 20 $ 93.80 2 $ 3.50 $ 8.69 $132.86 12 Steel-Cut Irish Oatmeal Hot Chocolate Tax Amount Due

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.3: Interactive While Loops
Problem 5E
icon
Related questions
Question

Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following:

  1. Show the customer the different breakfast items offered by the restaurant.
  2. Allow the customer to select more than one item from the menu.
  3. 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) $1.99
Golden-Brown Pancake $1.99
French Toast $2.99
Muffin $0.99
Bagel w/ Spread $1.20
Fresh Fruit $3.49
Steel-Cut Irish Oatmeal $4.69
Coffee $1.50
Pot of Assorted Tea $1.75
Hot Chocolate $1.75

Define a struct named MenuItem with two components: name of type string and price of type double. Use an array of the struct MenuItem to store each menu item and a parallel array to store the quantity of each item a customer orders.

Your program must contain at least the following functions:

  1. Function getData: This function loads the item and price data from a text file named menu.txt (with a lowercase m) into the array of MenuItems. You will need to create the text file that contains this menu information. Format your text file so that it works well for your program (you may pick the format). This function should have two parameters: (1) an array of MenuItems and (2) the array length. The function should return the number of items read from the file.
    Hint: If you use getline() to read the entire line as each menu item’s name, you will need to ignore the rest of the line after reading in the price as a double. There is also a 3-parameter overload of getline() that allows you to change the default delimiter ('\n') to another character like a tab ('\t').
  2. Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items. As expected, this function will need access to the MenuItems and know the number of items. It should not modify the MenuItems, so make that first parameter const. The function should show the welcome message first as shown in the example output below.
  3. Function makeSelection: This function repeatedly asks the customer if they would like to make a selection until the enter an N or n. If the customer enters Y or y, the program gets a menu item by number and a quantity from the customer. Validate the user input and store the quantities of each item purchased in a parallel array of integers. This function should not reference or modify the menuList array. See the example output below for what prompts to provide. If the user selects the same item number twice, replace the original quantity with the latest quantity.
  4. Function printReceipt: This function calculates and prints the check. It requires the two parallel arrays as parameters: (1) the MenuItem array, (2) the int array, and (3) the array size. (Note that the billing amount should include a 7% sales tax.)
 

Format your output as shown in the example. The name of each item in the output must be left justified. Right justify the price and quantities.

Upload your source code (Restaurant.cpp) and the text file with the menu information. 

 

In C++ Programming

Sample Output (user input is in yellow)
Welcome to the Programmers' Cafe
---Today's Menu--
1: Egg (cooked to order)
2: Golden-Brown Pancake
$1.99
$1.99
$2.99
$0.99
$1.20
$3.49
7: Steel-Cut Irish Oatmea1 $4.69
$1.50
$1.75
$1.75
3: French Toast
4: Muffin
5: Bagel w/ Spread
6: Fresh Fruit
8: Coffee
9: Pot of Assorted Tea
10: Hot Chocolate
Do you want to place an order? (y/n): y
Enter item number: 12
Enter item number between 1 and 10: 1
Enter item quantity: 12
Select another item? (y/n): y
Enter item number: 3
Enter item quantity: 1
Select another iten? (y/n): y
Enter item number: 7
Enter item quantity: 20
Select another item? (y/n): y
Enter item number: 10
Enter item quantity: 2
Select another item? (y/n): n
Thank you for eating at
The Progranners' Cafe
Receipt
Qty
Amount
Egg (cooked to order)
French Toast
$ 23.88
1 $ 2.99
20 $ 93.80
2 $ 3.50
$ 8.69
$132.86
12
Steel-Cut Irish Oatmeal
Hot Chocolate
Tax
Amount Due
Transcribed Image Text:Sample Output (user input is in yellow) Welcome to the Programmers' Cafe ---Today's Menu-- 1: Egg (cooked to order) 2: Golden-Brown Pancake $1.99 $1.99 $2.99 $0.99 $1.20 $3.49 7: Steel-Cut Irish Oatmea1 $4.69 $1.50 $1.75 $1.75 3: French Toast 4: Muffin 5: Bagel w/ Spread 6: Fresh Fruit 8: Coffee 9: Pot of Assorted Tea 10: Hot Chocolate Do you want to place an order? (y/n): y Enter item number: 12 Enter item number between 1 and 10: 1 Enter item quantity: 12 Select another item? (y/n): y Enter item number: 3 Enter item quantity: 1 Select another iten? (y/n): y Enter item number: 7 Enter item quantity: 20 Select another item? (y/n): y Enter item number: 10 Enter item quantity: 2 Select another item? (y/n): n Thank you for eating at The Progranners' Cafe Receipt Qty Amount Egg (cooked to order) French Toast $ 23.88 1 $ 2.99 20 $ 93.80 2 $ 3.50 $ 8.69 $132.86 12 Steel-Cut Irish Oatmeal Hot Chocolate Tax Amount Due
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr