Introduction

The goal of this project is for you to practice some of the more advanced topics we have covered in the course thus far, including streams, functions, and data collections, as well to see how you can extend existing applications to solve more complex problems. Specifically, you will be extending the restaurant program so that its menu can be edited and its contents saved in a file.

In addition to its normal functionality (accepting users' orders and calculating tax and tip), you'll add two new options to the menu, "+" and "-", which will allow a user to add and remove an item from the menu, respectively. You may (and are encouraged to) use the restaurant.cpp example provided on Canvas as a starting point for this project.

Requirements Specification

The following behaviors come from the original restaurant program:

1. Your program should print a nicely-formatted menu for the user, with a single-letter menu option on the left, followed by the menu item name, and the prices should be lined up on the right-hand side of the menu. Menu choices should start at "a", and below the menu items, there should be an option to exit the program using "x". As the menu is intended for patrons and not the owners, you should not include the new "+" and "-" options on the menu. (Note: you will need to rewrite this code to handle the fact that the menu is no longer constant. You may assume that menu item names are no more than 20 characters in length and that no item costs more than $99.99.)

2. Prompt the user for what items they would like, adding the cost of those items to their bill. Continue prompting the user until they enter "x" to indicate the end of their order.

3. When the user enters "x", your program should print out their subtotal, the tax (11%) and gratuity (18%) on their order, and the full total. All of these should be well-formattedthey should line up on the right, and they should all have two decimal places. You may assume that the total will not exceed $999.99.

4. If the user enters any choice that is not a valid menu option, your program should print the menu again, and re-prompt them for their order.

Your program will also need to provide extended functionality to allow for its changing menu:

5. When the program starts, before the menu is printed, you will need to read the menu in from a file. This operation should be implemented in a read_menu function that takes as arguments a const char* indicating the file name to read, as well as the variable(s) in which it should store the menu items. You should not use global variables to store your menu items.

a. The menu should be saved in the file menu.txt. This file should contain one line for each menu item, with the price as the first word on the line (just the amount, no "$") and the item name following that. Note that the name of the item may include multiple words.

b. For example, if the first item on the menu is a $7.95 order of crab cakes, the first line of menu.txt should be: 7.95 Crab cakes

6. Each time the menu is changed, whether through "+" or "-", your program should call a write_menu function that accepts a const char* indicating the file name to write, as well as the variable(s) containing the menu items. You should save the menu to menu.txt, in the format indicated above.

a. Both read_menu and write_menu (along with any other function you define outside of main) should be declared in a separate header file, restaurant.h.

7. If the user types "-", you should print the menu and prompt them for an item to remove (i.e., choice "a" through the last item on the menu). If there are no menu items left, you should print "Menu empty" instead and return to the menu prompt.

a. If they choose a valid item, you should delete that item from the menu, shifting every item that appears after it up one spot, and save the changes.

b. Afterwards (or if they enter an invalid menu option), return to the menu prompt them for another item to order. Removing an item should not affect a customer's current order.

8. If the user types "+", you should prompt the user for the name and price of the new item, in that order. However, the menu should hold at most 20 items (i.e., items "a"-"t"), so if the menu already has 20 items, you should print the message "Menu full" instead of prompting for the name and price.

a. If the user enters a bad price (non-numeric value, zero, or negative amount), prompt them for the price again until they enter a valid value. Note that the item name may include multiple words.

b. If that item already exists on the menu (i.e., its name exactly matches an existing menu item), you should change the existing item's price to match the price entered by the user.

c. If the item isn't already on the menu, you should add the new item to the menu as the last item.

d. In either case (b or c), save the changes to the menu and return to the menu prompt. The change to the menu should not affect the customer's current order.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.