для чего предназначена программа: эта программа представляет собой систему бронирования авиабилетов, где места забронированы, каждый раз, когда она забронирована, она находится в сеансе, в итоговое резюме должны быть добавлены все итоги сеанса и указаны окончательные цифры.
проблема: проблема, с которой я сталкиваюсь, заключается в том, что итоговое резюме не рассчитывается должным образом, и мне интересно, может ли кто-нибудь посоветовать мне, почему оно не рассчитывается должным образом. Весь код необходим, и я не могу сделать проблему короче, чтобы объяснить проблему.
adult_price = 120
child_price = 60
availble_seats = 152
t_adult_s_s = 0
t_child_s_s = 0
t_total_s = 0
seats_left = 0
# stating values which stay constant through out the code#
while True:
print("*****************************************")
print(" Welcome to freezy jet ")
print("*****************************************")
print("We have 152 seats avalible to be booked")
print("- - - - - - - - - - - - - - - - - - - - ")
print("Adult tickets are £120 per seat")
print("Child tickets are £60 per seat")
print("*****************************************")
# while True:
while True:
try:
adult_ticket = int(input("How many adult tickets would you like to purchase "))
except ValueError:
print("Please try again")
# if user enters string or float message displays#
continue
if adult_ticket < 0:
print("Please try again to book with postive number")
# if user tries to enter a minus number this message is displayed#
continue
else:
break
while True:
try:
child_ticket = int(input("How many child tickets would you like to purchase "))
except ValueError:
print("Please try again")
continue
if child_ticket < 0:
print("Please try again to book with postive numbers")
continue
else:
break
total_ticket = adult_ticket + child_ticket
if total_ticket > 152:
# if user tries to purchase more than 152 tickets this message is displayed#
print("We are not able to sell you that many tickets due to there being a limited amount of seats")
print("")
print("Please try again by purchasing less tickets")
print("")
continue
else:
print("- - - - - - - - - - - - - - - - - - - - - - - - - ")
print("")
print(" Session summary ")
print("The amount of adult tickets purhcased is", adult_ticket)
print("The amount of child tickets purchased is", child_ticket)
total_tickets_purchased = (adult_ticket + child_ticket)
print("The total tickets purchased is", total_tickets_purchased)
print("****************************************************")
adult_cost = adult_price * adult_ticket
# works out total cost of adult tickets#
child_cost = child_price * child_ticket
# works out total cost of child tickets#
total_cost = adult_cost + child_cost
print("The total cost of adult ticket is", adult_cost)
print("The total cost of child tickets is", child_cost)
print("The total cost of the tickets is", total_cost)
seats_left = availble_seats - child_ticket - adult_ticket
# works out how many seats are remaining#
print("The remaining seats left is", seats_left)
t_adult_s_s = t_adult_s_s + adult_ticket
t_child_s_s= t_child_s_s + child_ticket
t_total_s = t_adult_s_s + t_child_s_s
seats_left = seats_left - t_total_s
t_adult =adult_ticket * adult_price
t_child =child_ticket * child_price
t_total=t_adult + t_child
# ask if user wants to continue if they do show final summary if not carry on asking
question = input("press 's' if you want to stop press any other key to continue ")
if question == 's':
break
print("- - - - - - - - - - - - - - - - - - - - - - - - - ")
print("")
print(" final summary ")
print("The total amount of adult seats sold is", t_adult_s_s)
print("The total amount of adult seats sold is", t_child_s_s)
print("The total amount of seats sold is", t_total_s)
print("***************************************************")
print("Seats left is",seats_left)
print("Total price for adult seats sold is", t_adult)
print("Total price for child seats sold is",t_child)
print("Total price for seats sold is",t_total)
print("END")