Question
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
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.
Design a modular program that asks how many tickets for each class of seats were sold, and then displays the amount of income generated from ticket sales.
You will only write the javascript for the assignment as the pseudocode will be provided for you in this repl.it:
Function main() // get number of tickets for each class Integer classATickets = getTicketsForClass("A") Integer classBTickets = getTicketsForClass("B") Integer classCTickets = getTicketsForClass("C")
// get income for each ticket class Integer classAIncome = calculateIncome(classATickets,15) Integer classBIncome = calculateIncome(classBTickets,12) Integer classCIncome = calculateIncome(classCTickets,9)
Integer total = classAIncome + classBIncome + classCIncome Display "Total income: " + total End Function
Function getTicketsForClass(String letter) Display "How many tickets for class " + letter + " seats?" Integer ticketCount = Input return ticketCount End Function
Function calculateIncome(Integer ticketCount, Float ticketCost) return ticketCount * ticketCost End Function
// call main to start program main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started