大家好,我遇到的问题是电影院门票和部分。基本上,该程序应该接受输入的门票并产生总收入。一个要求是如果输入的门票数量超过该部分的座位限制,则执行无效功能。该程序运行良好,但当发生失效并输入适当数量的票时,它将计算导致失效功能执行的票,以及新售出的适当数量的票。请帮忙。谢谢!
secA = 20
secB = 15
secC = 10
def getTickets():
global A
A = int(input("Please enter the number of tickets sold in section A: "))
global B
B = int(input("Please enter the number of tickets sold in section B: "))
global C
C = int(input("Please enter the number of tickets sold in section C: "))
def ticketsValid(A,B,C):
while A > 300 or A < 0:
print("ERROR: Section A has a limit of 300 seats")
A = int(input("Please enter the number of tickets sold in section A: "))
while B > 500 or B < 0:
print("ERROR: Section B has a limit of 500 seats")
B = int(input("Please enter the number of tickets sold in section B: "))
while C > 200 or C < 0:
print("ERROR: Section C has a limit of 200 seats")
C = int(input("Please enter the number of tickets sold in section C: "))
def calcIncome(A, B, C):
incomeGenerated = A * secA + B * secB + C * secC
print("The income generated is $%d" % (incomeGenerated))
def main():
getTickets()
ticketsValid(A,B,C)
calcIncome(A, B, C)
main()