它没有打印出我想打印的东西

2024-05-15 16:33:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了我能做的一切,但它没有打印我想要的东西,只是出来了 电子售票自动化系统 成人人数:3 儿童人数:3 长者人数:3 什么样的会员资格1个为企业会员,2个为家庭会员:1 有信息输入错误,请重新输入以上信息

进程已完成,退出代码为“0”

print("E Ticketing Automation System")

#a for adult b for kids and c for elderly
a = int(input("Numbers of adult: "))
b = int(input("Numbers of kids: "))
c = int(input("Numbers of elderly: "))
membership = input("what kind of membership 1 for corporate  or 2 for 
family: ")

totalprice = (a*10.00) + (b*7.50) + (c*5.50)
kiddo=b*7.50


corporate = totalprice-(totalprice/100)*20
ccorporate=(totalprice/100)*20
family = totalprice-(b*7.50)


if membership == 1:
   print("The original price before discount is $,",totalprice,"after 20 
   percent discount",ccorporate, "the total price will be $",corporate, )
elif membership == 2:
   print("The original price is $",totalprice,"but after deduction of the 
   kids price $",kiddo,"the total price will be $",family,)
else:
   print("there is information inputted incorrectly pls re-enter the info 
   above.")

Tags: oftheforinputiscorporatefamilyprice
1条回答
网友
1楼 · 发布于 2024-05-15 16:33:02

我猜您忘记考虑变量^ {< CD1>}的输入,如^ {< CD2>}。

这是更新后的源代码

print("E Ticketing Automation System")

#a for adult b for kids and c for elderly
a = int(input("Numbers of adult: "))
b = int(input("Numbers of kids: "))
c = int(input("Numbers of elderly: "))
membership = int(input("what kind of membership 1 for corporate  or 2 for family: "))

totalprice = (a*10.00) + (b*7.50) + (c*5.50)
kiddo=b*7.50


corporate = totalprice-(totalprice/100)*20
ccorporate=(totalprice/100)*20
family = totalprice-(b*7.50)


if membership == 1:
   print("The original price before discount is $,",totalprice,"after 20 percent discount",ccorporate, "the total price will be $",corporate, )
elif membership == 2:
   print("The original price is $",totalprice,"but after deduction of the kids price $",kiddo,"the total price will be $",family,)
else:
   print("there is information inputted incorrectly pls re-enter the info above.")

预期产出:

E Ticketing Automation System
Numbers of adult: 3
Numbers of kids: 3
Numbers of elderly: 3
what kind of membership 1 for corporate  or 2 for family: 1
The original price before discount is $, 69.0 after 20 percent discount 13.799999999999999 the total price will be $ 55.2

相关问题 更多 >