Question: Please debug the code from below to make it can print the total number of passengers (including both children and adults) and also the total

Please debug the code from below to make it can print the total number of passengers (including both children and adults) and also the total price of all the tickets combined. Tickets are $4 for each adult and free for children 12 years and under. (the copy of the code will also provide underneath the picture.

Please debug the code from below to make it can print thePlease debug the code from below to make it can print the total number of passengers (including both children and adults) and also the total price of all the tickets combined. Tickets are $4 for each adult and free for children 12 years and under. (the copy of the code will also provide underneath the picture.

total number of passengers (including both children and adults) and also thetotal price of all the tickets combined. Tickets are $4 for each

import sys

total_passengers = 0 total_price = 0 while True: user_input = input("Enter the passenger's age: ")

numeric = '0123456789' i = 0 num = False j = 0 while j

if user_input == "q" or user_input == "": print() break

if int(user_input) 12: print("One adult ticket added") total_price += 4 print() total_passengers += 1

print("There are a total of {} passengers. The total cost of all the tickets is ${}.".format(total_passengers, total_price))

Question 3 The program tickets.py calculates the total price of train tickets for all boarding passengers. The program should continuously ask the user to input the age of the passenger the user either types q to quit or presses Enter without typing any input. Any non-integer age entries should be ignored. Furthermore, any zero or negative age entries should also be ignored. After each valid age entry, the program should output the message Children travel for free! if the passenger is 12 years or younger. Otherwise, it should output the message One adult ticket added. At the end, the program should print the total number of passengers (including both children and adults) and also the total price of all the tickets combined. Tickets are $4 for each adult and free for children 12 years and under. tickets.py 1 import sys 2 3 total_passengers = 0 4 total_price = 0 5 while True: 6 ...user_input = input("Enter the passenger's age: ") 7 8 numeric = '0123456789 9 i = 0 10 num = False 11 j = 0 12 while j 12: 33 34 print("One adult ticket added") total_price += 4 print() total_passengers += 1 35 36 37 38 print("There are a total of {} passengers. The total cost of all the tickets is ${}.". format(total_passengers, total_price))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!