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

Create a program that will ask the user to choose their order from a simple menu....
Create a program that will ask the user to choose their order from a simple menu. Customers first choose from three types of dishes: Sandwiches/wraps, Rice Meals, or Noodles. They can type in 1, 2, or 3 to select the type then, they choose a specific dish as shown below. Confirm their order by displaying it on the screen after they make their selection. 1. Sandwiches/wraps Hamburger Chicken shawarma 2. Rice meals Arroz con pollo Chana masala 3. Noodles Chow...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT