Enter 10 for first input
enter 500 for second input
enter 20 for third input
我想知道是否有一种方法,我可以得到最大的利润,并显示它没有用户必须通过阅读每一行?你知道吗
MP=abs(int(input("Enter the minimum number of passengers:")))
print(MP)
max_passengers=int(input("Enter the maximum number of passengers:"))
while(max_passengers <= MP):
print("\n")
max_passengers=int(input("You must enter a number that is greater than the minimum ammount of passengers:"))
print(max_passengers)
TP=float(input("Enter the ticket price"))
print(TP)
increment=10
fixed_cost=2500
print("\n")
for numberpass in range(MP,max_passengers+10,increment):
discount=.5
ticketcost = TP - (((numberpass - MP) /10) * discount)
gross=numberpass*ticketcost
profit=gross-fixed_cost
print(numberpass,"\t",ticketcost,"\t",gross,"\t",fixed_cost,
"\t",profit)
将所有利润保存在列表中,然后取该列表的最大值:
相关问题 更多 >
编程相关推荐