这是用户的购物车,计算其总数并列出产品。我很难在底部定义税收" wdeposit"我还有一些事要做。然后如何显示两个单独的总计。 然后我打算用
while 1:
action=input("press any key if you like to purchase otherwise type end to finish")
if action=="end"
break
我希望这将是一个很好的结局。希望有人可以帮我完成我的作业。提示会更有帮助,所以我可以学习,而不是实际上有人为我做。感谢。
#Welcome user to user display product and prices
print("Hello, welcome to the store")
print("This is the list & products")
print("0,Milk,$2.39/Gallon")
print("2,Eggs,$1.58/per dozen")
print("4,Water,$1.00/Bottle+$.05 deposit")
print("6,Soda,$.99/Can+$.05 deposit")
print("8,Bread,$2.99/Loaf")
print("10,Chips,$1.30/Bag")
print("12,Tomato,$1.99/Pound")
print("Ready-food box,$8.99/Box+$.0625 tax")
#Prompt users for his product
totalpurchase=0
choice=int(input("Enter your product code"))
if choice==0:
qofmilk=int(input("How many gallons do you wish to purchase?"))
totmilk=qofmilk*2.39
print("Your total price for milk is", totmilk)
totalpurchase=totalpurchase+totmilk
if choice==2:
qofeggs=int(input("How many dozen of eggs do you wish to purchase?"))
toteggs=qofeggs*1.58
print("Your total price for eggs is", toteggs)
totalpurchase=totalpurchase+toteggs
if choice==4:
qofwater=int(input("How many bottles of water do you wish to purchase?"))
totwater=qofwater*1.00
print("Your total price for water is", totwater)
totalpurchase=totalpurchase+totwater
if choice==6:
qofsoda=int(input("How many cans of soda do you wish to purchase?"))
totsoda=totsoda*.99
print("Your total price for soda is", totsoda)
totalpurchase=totalpurchase+totsoda
if choice==8:
qofbread=int(input("How many loafs of bread do you wish to purchase?"))
totbread=totbread*2.99
print("Your total price for bread is", totbread)
totalpurchase=totalpurchase+totbread
if choice==10:
qofchips=int(input("How many bags of chips do you wish to purchase?"))
totchips=totchips*1.30
print("Your total price for chips is", totchips)
totpurchase=totalpurchase+totchips
if choice==12:
qoftomato=int(input("How many pounds of tomatoes do you wish to purchase?"))
tottomato=tottomato*1.99
print ("Your total price for tomatoes is", tottomato)
totpurchase=totpurchase+tottomato
if choice==14:
qofchicken=int(input("How man pounds of chicken do you wish to purchase?"))
totchicken=totchicken*2.99
print("Your total price for chicken is", totchicken)
totpurchase=totpurchase+totchicken
if choice==16:
qofready=int(input("How many boxes of ready-food boxes do you wish to purchase?"))
totready=totready*8.99
print("Your total price for ready-food boxes is", qofready)
totpurchase=totpurchase+totready
if choice==4:
wdeposit=wdeposit*.05
print("$.05 deposit", wdeposit)
答案 0 :(得分:0)
行wdeposit=wdeposit*.05
应该基于瓶装水的数量(qofwater * 0.05
)。您有if choice==4:
两次,但您只需要一次。您可以将wdeposit
计算放在同一个区块中,向用户询问他们想要购买多少瓶水。