“我正在编写代码以提示用户用餐,并告知他们GCT之前和之后的费用”
上下文/背景: 曼彻斯特一家小型快餐店的老板米切尔(Mitchell)先生决定,他要一家商店使用计算机化系统。您需要编写一个程序来接受基于菜单的来自客户的订单和现金。然后,程序应计算并显示订单成本,包括GCT金额和客户变更。订单包括餐点,饮料和小菜。每个项目应有一个单独的菜单。选择每个项目时,应采用16.5%的GCT来产生总成本。然后,客户应该能够自己支付餐费,如果金额大于或小于总费用,则应采取适当的措施。打印出交易收据,包括购买的物品及其价格,GCT之前的总成本,GCT之后的总成本,客户支付的总金额以及客户收到的零钱。
gct= 0.165
order=0
print("=============================Welcome to Mitchell's==========================")
print("====================================={MEALS}===================================")
print(" 1: Fried chicken and Rice: $400 " ," 2: Curred Chicken : $400 "," 3: Bbq Chicken : $450 "," 4: Fry Fish : $500 ")
print('\n')
print("===================================={DRINKS}===================================")
print("Water : $80 ","Soda : $100 ","Smoothie : $150")
print('\n')
print("===================================={SIDES}=====================================")
print("Fries : $200 ","Pasta : $100 ","Coleslaw : $100 ")
print('\n')
meal=[" 1: Fried chicken and Rice" ," 2: Curred Chicken"," 3: Bbq Chicken"," 4: Fry Fish"]
drink=["Water","Soda","Smoothie"]
sides=["Fries","Pasta","Coleslaw"]
print('\n')
choice=(input("Type of order: 1: Meals 2:Drinks 3:Sides: "))
if choice == 1:
x= meal.copy()
def MEAL(gct,order):
select=(int(input("Select Meal Choice: ")))
amount=(int(input(" Quantity: ")))
if select==1:
food = 400
total = (food*gct)+food
final = total*amount
print(final)
elif select==2:
food = 400
total =(food*gct)+food
final = total*amount
print(final)
elif select==3:
food = 450
total =(food*gct)+food
final = total*amount
print(final)
elif select==4:
food = 500
total =(food*gct)+food
final = total*amount
print(final)
num=(int(input("Do you want to add another meal 1 for yes 2 for No")))
if num == 1:
order=final
final = final*amount
print(order)
MEAL(gct,order)
elif num == 2:
final =order+final
order=final+order
print(final)
print(order)
exit
MEAL(gct,order)
问题:
问题结束时,每当我按num=(int(input("Do you want to add another meal 1 for yes 2 for No")))
时我就有1
没问题,但是如果我按2
,我的计算就不正确,例如,如果上面的食物价格为$ 400在GCT之前,GCT之后应该给$ 466,但不是给我那么多的钱,而是给与更多或相同的$ 400