Improved Taking a Restaurant Order Program.
Create a new version of the restaurant ordering program BELOW that uses lists to look up menu items, record the items ordered by the user, and print a full receipt. The following requirements:
a. Use a list to look up the names of the menu items; call this list menu_items. This list will replace the use of the multi-way condition. Create the list with the names of the menu items, in the order they appear in the program you created for Part X of Assignment Y. Notice that, because the first position in a list is zero (0), item number 1 in the menu is stored in menu_items[0].
b. Use a list to look up the prices of the menu items; call this list menu_prices. This list will also replace the use of a multi-way condition to obtain this information. Create the list with the prices of the menu items. Make sure this list aligns with the list in part (a) above. That is, for index value item_nro, the price in menu_prices[item_nro] corresponds to the dish in menu_item[item_nro].
c. Use a list to record the items ordered by the user; call this list ordered_items. This list contains the items’ menu numbers, not their names.
d. Use a list to record the quantity of each item ordered; call this list ordered_quantity. Make sure this list aligns with the ordered_items list. That is, for example, if the customer first orders 3 Cheese Sandwiches (item 7 in the menu), and then 2 Sodas (item 10), then ordered_items[0] is 6, ordered_quantity[0] is 3, ordered_items[1] is 9, and ordered_quantity[1] is 2.
e. After taking an order, the program prints a full receipt, listing the items ordered, quantities, and prices, together with subtotal, tax, tip, and grand total. You can look at a sample receipt from the restaurant you selected, or search online for “restaurant receipt,” for the overall layout of the receipt.
import sys
#Define the function Menu that displays the menu
def Menu():
print("Menu Card")
print("1. Cajun Calamari price is $9.00")
print("2. Shrimp Cocktail price is $9.00")
print("3. Spicy Garlic Mussels price is $9.00")
print("4. Crispy Ahi price is $10.50")
print("5. Spinach Artichoke Dip price is $8.00")
print("6. Steamed Clams price is $10.00")
print("7. Chips and Dip price is $6.50")
print("8. Beer Battered Ribs price is $6.00")
print("9. St.Louis Ribs price is $8.00")
print("10. Mozzarella Sticks price is $7.00")
#Define the function that read the user input and return the subtotal
def userInputCalc():
prices = 0
subtotal =0
continueLoop ="y"
#Enter number for each dish and price for users
while continueLoop =="y":
DishNumber= int(input("\nEnter numbers between 1 and 10:"))
if DishNumber == 1:
prices = 9.0
print("Cajun Calamari price is $",prices)
elif DishNumber== 2:
prices = 9.0
print("Shrimp Cocktail price is $",prices)
elif DishNumber== 3:
prices = 9.0
print("Spicy Garlic Mussels price is $",prices)
elif DishNumber== 4:
prices = 10.50
print("Crispy Ahi price is $",prices)
elif DishNumber== 5:
prices = 8.0
print("Spinach Artichoke Dip price is $",prices)
elif DishNumber== 6:
prices = 10.0
print("Steamed Clams price is $",prices)
elif DishNumber== 7:
prices = 6.50
print("Chips and Dip price is $",prices)
elif DishNumber== 8:
prices = 6.0
print("Beer Battered Ribs price is $",prices)
elif DishNumber== 9:
prices = 8.0
print("St.Louis Ribs price is $",prices)
elif DishNumber== 10:
prices = 7.0
print("Mozzarella Sticks price is $",prices)
else:
print("You have selected an invalid input.")
continueLoop = input("\nEnter y to Continue or n to quit:")
subtotal = subtotal + prices
return subtotal
#Calculate tax, total, tip
def total(subtotal):
sales_tax = subtotal*0.085
subtotal = subtotal + sales_tax
tip = subtotal*0.15
grand_total = subtotal + tip
return sales_tax, grand_total, tip
#Define the function that print receipt
def printReceipt(subtotal, sales_tax, grand_total, tip):
print("\n------Reciept------")
print("\nSubtotal: ",subtotal,"$")
print("Sales tax : ",sales_tax,"$")
print("Grand total : ",grand_total,"$")
print("Suggested tip : ",tip,"$")
#Define the main function
def main():
Menu()
subtotal = userInputCalc()
sales_tax, grand_total, tip =total(subtotal)
printReceipt(subtotal, sales_tax, grand_total, tip)
main()
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Write a Do While loop that counts from 12-24. This loop will produce a list box that will contain those values. Submit code only.arrow_forwardCode following instructions using pyhton: 1. Write a function that accepts a list as an argument (assume the list contains integers) and returns the total of the values in the list 2.Draw a flowchart showing the general logic for totaling the values in a list. 3.Assume the names variable references a list of strings. Write code that determines whether 'Ruby' is in the names list. If it is, display the message 'Hello Ruby'. Otherwise, display the message 'No Ruby'.arrow_forwardCreate a function that compares two lists of integer values to see whether they are identical (i.e. contain the same values). If the lists are not identical, the procedure must give the maximum value for each list.arrow_forward
- Please send me answer of this question immediately and i will give you like sure sirarrow_forwardWrite a nested if statement that will determine the student's final letter grade. Display the numeric and letter grades for the Final average and final exam. Write the nested code in python. import randomdef main(): # main function definition aGrades=[] # empty list to store Grades for i in range(7): # loop to read 7 inputs print("Input scores ",i+1," : ", end="") # a message to enter grade n=int(input()) # input grade aGrades.append(n) # add grade into list print("Grade list before randomize: ",aGrades) # print list random.shuffle(aGrades) # randomize list numExams=len(aGrades)-1 # compute numExams FinalExam=aGrades[-1] # store final grade TotalPoints=sum(aGrades)-aGrades[-1] # compute TotalPoints TestAverage=TotalPoints/numExams # compute TestAverage FinalAverage=TestAverage*.6 + FinalExam*.4 # compute FinalAverage print("Grade list after randomize is: ",aGrades) # print list print("Test Average =…arrow_forwardPython programming only NEED HELP PLEASEarrow_forward
- python LAB: Subtracting list elements from max When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. Write a program that adjusts a list of values by subtracting each value from the maximum value in the list. The input begins with an integer indicating the number of integers that follow.arrow_forwardWrite a program that uses 2 lists. Call the lists Items and Basket respectively. The first list will contain a list of at least 10 items (make up your own items) to select from. The second list will be used to add the selected items in the new list.(Basket) Your program should do the following in a Loop until the user exits the loop: Display the list (print out 1, 2, 3, 4, etc. before each item in the list (Hint: Use Index + 1) Prompt the user to select an item from the Items list. Add the selected item to the new list (Basket) (HINT: Use number entered - 1 for the Index) When the user selects 0, exit the loop and print out the new list of items (Basket) Use Microsoft Word to create your Outline and Logic sections. You can copy and paste your Python code at the end under the heading "Code:" Upload your work into the assignment when completedarrow_forwardIn python Create a list from the items in the Bonjoir le monde! String and assign it to the liste variable. Hint: use the list function to built a liste from an it érable sequence (e.g. a string).arrow_forward
- Computer Science Part C: Interactive Driver Program Write an interactive driver program that creates a Course object (you can decide the name and roster/waitlist sizes). Then, use a loop to interactively allow the user to add students, drop students, or view the course. Display the result (success/failure) of each add/drop.arrow_forwardPython code. Please write your own code. Thank you!arrow_forwardi need to add the loop with the lists to my code can you help. see code and the part that i need to add.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY