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 program names EncryptDecrypt.java that has the following menu choices: Print menu and allow user...
Write a program names EncryptDecrypt.java that has the following menu choices: Print menu and allow user to choose options. The program must have a file dialogue box for text file. Output should be based on user choices. Read in a file Print the file to the console Encrypt the file and write it to the console Write out the encrypted file to a text file Clear the data in memory Read in an encrypted file Decrypt the file Write out...
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
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(")...
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(") " + entry) return int(input(question)) plz explain this code
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT