Question

In: Computer Science

print a menu so that the user can then order from that menu. The user will...

print a menu so that the user can then order from that menu. The user will enter each item they want until they are done with the order. At the end you will print the items the user ordered with their price and the total.

Note: You will be storing your menu items (pizza, burger, hotdog, salad) and your prices (10, 7, 4, 8) in separate lists.

Menu
0) pizza $10
1) burger $7
2) hotdog $4
3) salad $8
Enter the number of the item you want to order: 0
Are you done ordering? (yes or no) no
Enter the number of the item you want to order: 2
Are you done ordering? (yes or no) no
Enter the number of the item you want to order: 2
Are you done ordering? (yes or no) no
Enter the number of the item you want to order: 3
Are you done ordering? (yes or no) yes

Final order: 
pizza @ $10
hotdog @ $4
hotdog @ $4
salad @ $8
Total price: $26

Solutions

Expert Solution

Source Code:

Output:

Code in text format (See above image of code for indentation):

#menu and prices are stored in two separate lists
menu=["pizza","burger","hotdog","salad"]
prices=[10,7,4,8]
#orders and its prices lists
order=[]
p=[]
#total amount
total=0
#print menu
print("Menu")
for i in range(len(menu)):
print(i,")",menu[i],"\t$",prices[i])
while(True):
#read options from user
option=int(input("Enter the number of the item you want to order: "))
#add order and its price to lists
order.append(menu[option])
p.append(prices[option])
#calculate total
total+=prices[option]
#ask user to stop or to continue
ch=input("Are you done ordering?(yes or no) ")
#if yes break
if(ch=="yes"):
break
print()
#print final order
print("Final order:")
for i in range(len(order)):
print(order[i]," @ $",p[i],sep='')
#print total
print("Total price:$",total)


Related Solutions

Write a C++ code to print to the user a simple menu of a fast food...
Write a C++ code to print to the user a simple menu of a fast food restaurant. You should allow the user to select his/her preferred burgers and/or drinks and you should display the final bill to the user for payment. The user should be able to select more than one item. You should use the switch statement.
Implement a class called DoublyLinkedList. In the main function, instantiate the DoublyLinkedList class and make sure that there is a user loop and a menu so that the user can access all the list operators.
C++  Implement a class called DoublyLinkedList. In the main function, instantiate the DoublyLinkedList class and make sure that there is a user loop and a menu so that the user can access all the list operators. You should implement the following operators, and any others that you may deem best. DestroyList InitializeList GetFirst InsertFirst, InsertLast, Insert DeleteFirst, DeleteLast, Delete IsEmpty Length Print, ReversePrint
Write a program that will print the whole numbers from a user-specified minimum to a user-specified...
Write a program that will print the whole numbers from a user-specified minimum to a user-specified maximum. Display the total amount of numbers printed.
You must prompt the user to enter a menu selection. The menu will have the following...
You must prompt the user to enter a menu selection. The menu will have the following selections (NOTE: all menu selections by the user should not be case sensitive): 1. ‘L’ – Length a. Assume that a file containing a series of names is called names.txt and exists on the computer’s disk. Read that file and display the length of each name in the file to the screen. Each name’s middle character or characters should be displayed on a line...
how to write a cpp program that takes a number from a user, and print the...
how to write a cpp program that takes a number from a user, and print the sum of all numbers from one to that number on screen? using loop interation as basic as possible.
C++ CODE Change your code from Part A to now present a menu to the user...
C++ CODE Change your code from Part A to now present a menu to the user asking them for an operation to perform on the text that was input. You must include the following functions in your code exactly as provided. Additionally, you must have function prototypes and place them above your main function, and the function definitions should be placed below the main function. Your program should gracefully exit if the user inputs the character q or sends the...
Linux Given a passed parameter to a script, request a number from the user and print...
Linux Given a passed parameter to a script, request a number from the user and print the parameter as many times as that number.
Build and present a menu to a user like the following and enclose it into a...
Build and present a menu to a user like the following and enclose it into a loop that ends when the Quit option is chosen. Scan the user's selection into an integer variable. 1. Enter user name. 2. Enter test scores. 3. Display average. 4. Display summary. 5. Quit. Selection: If the user selects Option #1, scan the user's name, and store it to a char array. Assume the user's name is under 20 characters. If the user selects Option...
Answer the questions –- Print so I can read it in PeN 1) Assume that a...
Answer the questions –- Print so I can read it in PeN 1) Assume that a solvent having more isopropanol than solvent G was used in the experiment. Predict whether dye A would migrate a smaller or larger distance in this solvent than in solvent F or G. Why? 2) TLC can be used to help identify unknown compounds. Explain how this might be accomplished using the dyes as an example. 3) READ Harris page 604-623 – define the following...
C++ Linkedlist Create a food menu so the customer can see what we are selling, if...
C++ Linkedlist Create a food menu so the customer can see what we are selling, if the users place order that not on the menu, prompt the users to enter again. Food code and food must be matched when users enter.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT