Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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 ]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education