Pleaser fix the code below: Since functions should do a single logical task, there is no need for the userInputCalc function to collect the info and also do the summary calculations, so move line 61 to line 72. Then, place line 67-72 inside a main() function, and place a call to this function at the end of the program file. Also, fix the names of the menu items (in menu_items) with spaces so they all have the same size. also, there is a simpler way: change {:<15} with {:<20} in lines 22 and 25. Also, use format for the “Subtotal” and “Grand total” (just like you did for “Sales tax” and “Suggested tip”) Also, the $ should go in front of the
Pleaser fix the code below:
Since functions should do a single logical task, there is no need for the userInputCalc function to collect the info and also do the summary calculations, so move line 61 to line 72. Then, place line 67-72 inside a main() function, and place a call to this function at the end of the program file.
Also, fix the names of the menu items (in menu_items) with spaces so they all have the same size.
also, there is a simpler way: change {:<15} with {:<20} in lines 22 and 25. Also, use format for the “Subtotal” and “Grand total” (just like you did for “Sales tax” and “Suggested tip”)
Also, the $ should go in front of the each amount.
PLEASE MAKE THOSE CHANGES IN THE CODE BELOW:
Summary
This program will create a new version of the restaurant ordering program
that uses lists to look up menu items, record the items ordered by the user,
and print a full receipt.
'''
def Menu(menu_items,menu_prices):
print("Menu Card")
count = 1
for i,j in zip(menu_items,menu_prices):
print("{}. {} price is {:.2f}$".format(count,i,j))
count+=1
def printReceipt(ordered_items,ordered_quantity,menu_prices,menu_items):
subtotal = 0
print("{:<15} {:<10} {:<7} {:<7}".format("Items","Quantity","Rate","Total"))
for i,j in zip(ordered_items,ordered_quantity):
subtotal += j*(menu_prices[i])
print("{:<15} {:<10} {:5.2f} {:5.2f}".format(menu_items[i],j,menu_prices[i],j*menu_prices[i]))
tax = 0.085*subtotal
tip = 0.15*subtotal
grand = subtotal+tax+tip
print("\n------Reciept------")
print("\nSubtotal: ",subtotal,"$")
print("Sales tax : {:.2f}$".format(tax))
print("Grand total : ",grand,"$")
print("Suggested tip : {:.2f}$".format(tip))
def userInputCalc(menu_items,menu_prics,ordered_items,ordered_quantity):
continueLoop = 'y'
while continueLoop=='y':
Menu(menu_items,menu_prices)
DishNumber = int(input("\nEnter numbers between 1 and 10:"))
if DishNumber<1 or DishNumber>10:
print("Invalid Input")
continue
print("{} is {}$".format(menu_items[DishNumber-1],menu_prices[DishNumber-1]))
quantity = int(input("Enter Quantity: "))
if quantity < 1:
print("Invalid Input")
continue
ordered_items.append(DishNumber-1)
ordered_quantity.append(quantity)
continueLoop = input("\nEnter y to Continue or n to quit:")
printReceipt(ordered_items,ordered_quantity,menu_prices,menu_items)
menu_items = ["Cajun Calamari","Shrimp Cocktail","Spicy Garlic Mussels","Crispy Ahi","Spinach Artichoke","Steamed Clams","Chips and Dip","Beer Battered Ribs",
"St.Louis Ribs","Mozzarella Sticks"]
menu_prices = [9,9,9,10.5,8,10,6.5,6,8,7]
ordered_items = []
ordered_quantity = []
userInputCalc(menu_items,menu_prices,ordered_items,ordered_quantity)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









