what program is meant to do: this program is a airline booking system where seats are booked, each time it is booked it is in a session, the final summary must add all the session summary's up and give the final figures.
problem: the problem I am facing is that the final summary does not calculate properly and I am wondering if anyone can advise me on as why it isn't calculating properly. All the code is needed and I cant make the problem shorter to explain the problem.
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")
Aucun commentaire:
Enregistrer un commentaire