There are three seating categories at a stadium. For a softball game, Class A seats cost $15,Class B seats cost $12, and Class C seats cost $9. Write a program that asks how many tick-ets for each class of seats were sold, and then displays the amount of income generated from ticket sales.
Python program code:
#The method 'calculate_income' is used to
#the amount of income generated from ticket sales
def calculate_income(class_a_tickets, class_b_tickets, class_c_tickets):
class_a_income = class_a_tickets * 15
class_b_income = class_b_tickets * 12
class_c_income = class_c_tickets * 9
total_income = class_a_income + class_b_income + class_c_income
return total_income
#main method
def main():
#Prompt and asks how many tick-ets for each class
#of seats were sold, and then displays the amount
#of income generated from ticket sales.
class_a_tickets = int(input("Enter the number of Class A tickets sold: "))
class_b_tickets = int(input("Enter the number of Class B tickets sold: "))
class_c_tickets = int(input("Enter the number of Class C tickets sold: "))
#Call the method
total_income = calculate_income(class_a_tickets, class_b_tickets, class_c_tickets)
#Display output
print("Total income from ticket sales: $", total_income)
if __name__ == "__main__":
main()
Executed Output:
Enter the number of Class A tickets sold: 100
Enter the number of Class B tickets sold: 100
Enter the number of Class C tickets sold: 200
Total income from ticket sales: $ 4500