In: Computer Science
n Python
There are three seating categories at a stadium. Class A seats cost $20, Class B seats cost $15, and Class C seats cost $10. Write a program that asks how many tickets for each class of seats were sold, then display the amount of income generated from ticket sales. \
your program MUST contain a main function, a calcIncome function, and a showIncome function.
Your main function should get the number of seats sold for each category. The values should be sent to a calcIncome function.
The calcIncome function should calculate the income from each category. Those values should be returned to the main function and those values should be sent to the showIncome function.
The showIncome function should calculate the total income generated from the ticket sales, display the income generated from each category AND display the total income generated.
The python code:
# calcIncome function that takes 3 parameters, number of tickets of
# type A,B and type C sold and returns the revenue generated from each
def calcIncome(a, b, c):
return (a * 20), (b * 15), (c * 10)
# showIncome function that takes 3 parameters , total income from A,B,C
# It adds all three to find the total income generated and prints the result
def showIncome(A, B, C):
total_income = A + B + C
print("Income generated by class A: {}".format(A))
print("Income generated by class B: {}".format(B))
print("Income generated by class B: {}".format(B))
print("Total income generated: {}".format(total_income))
# Main function that takes user input and calls calcIncome to
# calculate the income and the show Income that pints the income
def main():
A = int(input("Enter the number of seats sold of class A: "))
B = int(input("Enter the number of seats sold of class B: "))
C = int(input("Enter the number of seats sold of class C: "))
incomeA, incomeB, incomeC = calcIncome(A, B, C)
showIncome(incomeA, incomeB, incomeC)
# Calling the main function
main()
Screenshot of code for reference:
Screenshot of output: