Ask Question
2 February, 10:03

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 displays the amount of income generated from ticket sales.

+5
Answers (1)
  1. 2 February, 11:22
    0
    Following are the program to this question:

    def calculate_income (num, seat) : #defining method calculate_income

    if seat=="A": #defining condition for seat a

    return num * 20 #return value

    if seat=="B": #defining condition for seat b

    return num * 15 #return value

    if seat=="C": #defining condition for seat c

    return num * 10 #return value

    def show_income (a, b, c) : #defining method show_Income

    sum=a+b+c # add total seats income

    print ("Income for A class seats: $", a) #print value

    print ("Income for B class seats: $", b) #print value

    print ("Income for C class seats: $", c) #print value

    print ("Total Income: $", sum) #print value

    def main () : # defining main method

    a=int (input ("Enter class A seats: ")) #input seats a value

    b=int (input ("Enter class B seats: ")) #input seats b value

    c=int (input ("Enter class C seats: ")) #input seats c value

    a_income=calculate_income (a,"A") #call method for seat a

    b_income=calculate_income (b,"B") #call method for seat b

    c_income=calculate_income (c,"C") #call method for seat c

    show_income (a_income, b_income, c_income) # call method show_income for print all seat value

    main ()

    Output:

    Enter class A seats: 2

    Enter class B seats: 3

    Enter class C seats: 2

    Income for A class seats: $ 40

    Income for B class seats: $ 45

    Income for C class seats: $ 20

    Total Income: $ 105

    Explanation:

    The description of the above program can be described as follows:

    In the above python program, three methods "calculate_income, show_income, and the main method" were defined. The method "calculate_income" accepts two-variable "num and seat" as the parameter, inside the method a three if block is used, that calculate all types of seat class rate and returns its value. In the "show_income", we add all the seat value in the sum variable and use the print method, that prints all seat cost, and total cost. In the main method, we input all seat value from user input and pass into the calculate_income method and collect all the return value, after calculating calculate_income we pass its return value into the show_income method, that prints all value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers