Answer:
- section_a_cost = 20
- section_b_cost = 15
- section_c_cost = 10
-
- seatA = int(input("Input number of ticket sold in Section A: "))
- seatB = int(input("Input number of ticket sold in Section B: "))
- seatC = int(input("Input number of ticket sold in Section C: "))
-
- if(seatA < 0 or seatA > 300):
- print("Input Section A must be between 0 - 300!")
- elif(seatB < 0 or seatB > 500):
- print("Input Section B must be between 0 - 500!")
- elif(seatC < 0 or seatC > 200):
- print("Input Section C must be between 0 - 200!")
- else:
- income = (seatA * section_a_cost) + (seatB * section_b_cost) + (seatC * section_c_cost)
- print("Total income from ticket sales: $" + str(income))
Step-by-step explanation:
The solution code is written in Python 3.
Firstly, create three variables to hold the ticket cost for each section A, B and C (Line 1 - 3).
Next, prompt user to input number of ticket sold in Section A, B and C (Line 5 -7).
Validate the input value by using if else if statement to check if the input fall within the range of maximum seat in each section (Line 9 -14). If not, display error message. If the input pass all the validation, the program will calculate the total income from the ticket sales and display the result (Line 16 - 17).