CS161 Exercise 3, Restaurant Order Program solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

This assignment is designed to illustrate the use of tuples, lists and dictionaries in the python programming language
and the development of algorithms using those data structures.
1. A list of menu options will be stored in a tuple. These menu options will be displayed to the user to indicate desired
functionality. The menu options will be: Exit the program; Display the items on order; Add to the count of an ordered
item; Decrease the count of an ordered item; Add a new item to the order; and Delete an item from the order.
2. A list data structure will be used to contain the names of all items in the order.
3. You will use a dictionary structure to maintain a count of the ordered items. The dictionary will be indexed by the
item name, which you stored in the list data structure. The dictionary will also contain the count for each ordered
item.
Your program will behave as follows:
1. The program will prompt the user to select an operation from a menu. The menu will be stored in a tuple data
structure. The selection will be by menu item number:
0 – Exit
1 – Display the Order
2 – Add an Item to the Order
3 – Delete an Item from the Order
4 – Increase Count of an Item on Order
5 – Decrease Count of an Item on Order
2. The tuple data structure will be exactly:
menu = (“Exit”, “Display Order”, “Add an Item”, “Delete an Item”, “Increase Count of Item”, “Decrease Count of Item”)
As you can see, the menu item number is not part of the tuple and will have to be calculated when the menu is
displayed.
3. The inventory will start as an empty list data structure.
a. The “Display Order” menu item will display the items on order, along with the count of each item. New
items should be created with a count of 1.
b. To add a new item to the order, the program will prompt for a single string. The list will be updated
with the new item added to the order.
c. If the user attempts to add an item already on order, an error message will be displayed and the
program will return to the menu prompt as shown in item #1.
d. To remove an item from the order, the program should display the inventory items along with a
number in a manner similar to the menu in item #1. The item will be selected by number and not by
name.
4. The same approach used in 3(d) will be used for increasing and decreasing the count of an item already on
order. The program must ask the user for a number indicating the amount to increase or decrease the count for
that item. If the user subtracts a count that exceeds the current count, then an appropriate error message
should be displayed and the menu from item #1 displayed.
Not that if an item on order is reduced to zero, then the item should be removed from the order. Be sure to
allow for this.
Your program should account for obvious errors:
1. Trying to add an item already on order
2. Trying to delete an item not on order
3. Trying to delete more than the count listed for that item
Example Output Below (user input is underlined and in bold). The dashed lines are cosmetic only, so you do not need to
have them in your output. You may include different cosmetic style if you wish:
Welcome to the Restaurant Order Program!
What would you like to order?
Use the menu selections provided.
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
There are no items on order.
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 2
Enter Item Name: Veggie Burger
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 2
Enter Item Name: Veggie Burger
Error! That item is already on order.
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 2
Enter Item Name: French Fries
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
French Fries, quantity: 1
Veggie Burger, quantity: 1
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 4
Item 0 – French Fries, current quantity on order: 1
Item 1 – Veggie Burger, current quantity on order: 1
Enter menu item number to modify: 0
Amount to increase the item: 2
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
French Fries, quantity: 3
Veggie Burger, quantity: 1
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 5
Item 0 – French Fries, current quantity on order: 3
Item 1 – Veggie Burger, current quantity on order: 1
Enter menu item number to modify: 1
Amount to decrease the item: 2
Error! You cannot delete more items than are on order.
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 2
Enter Item Name: Soda
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
French Fries, quantity: 3
Veggie Burger, quantity: 1
Soda, quantity: 1
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 3
Item 0 – French Fries
Item 1 – Veggie Burger
Item 2 – Soda
Enter menu item number to delete: 1
Successfully Deleted: Veggie Burger
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
French Fries, quantity: 3
Soda, quantity: 1
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 5
Item 0 – French Fries, current quantity on order: 3
Item 1 – Soda, current quantity on order: 1
Enter menu item number to modify: 0
Amount to decrease the item: 2
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 1
French Fries, quantity: 1
Soda, quantity: 1
— — — — — — — — — — — —
0 – Exit
1 – Display the Order
2 – Add an Item
3 – Delete an Item
4 – Increase Count of Item
5 – Decrease Count of Item
Enter menu item number: 0