Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5. The manager of a football stadium wants you to write a program that calculate

ID: 3670708 • Letter: 5

Question

5. The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets box, sideline, premium, and general admission. After each game, data is stored in a file in the following form: ticket Price numberofTicketsSold Sample data are shown below: 250 5750 100 28 000 50 35750 25 18750 The first line indicates that the ticket price is $250 and that 5750 tickets were sold at that price. Output the number of tickets sold and the total sale amount. Format your output with two decimal places.

Explanation / Answer

import javax.swing.JOptionPane; public class CH3EX4 { public static void main(String[] args) { String inputStr; String outputStr; int noOfTicketsSoldBox; int noOfTicketsSoldSideline; int noOfTicketsSoldPremium; int noOfTicketsSoldGeneral; double totalBoxSaleAmount; double totalSidelineSaleAmount; double totalPremiumSaleAmount; double totalGeneralSaleAmount; inputStr = JOptionPane. showInputDialog ("Enter the total number of tickets sold for Box Admission"); // ** missing; noOfBoxTicketsSold= Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Enter the total number of tickets sold for Sideline Admission"); // ** missing; noOfSidelineTicketsSold = Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Enter the total number of tickets sold for Premium Admission") ; // ** missing; noOfPremiumTicketsSold = Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Enter the total number of tickets sold for General Admission"); // ** missing; noOfGeneralTicketsSold = Integer.parseInt(inputStr); totalBoxSaleAmount = noOfBoxTicketsSold * 250; totalSidelineSaleAmount = noOfSidelineTicketsSold * 100; totalPremiumSaleAmount = noOfPremiumTicketsSold * 50; totalSidelineSaleAmount = noOfGeneralTicketsSold * 25; outputStr = "Number Of Box Tickets Sold: " + (noOfBoxTicketsSold) + " " + "Box Total: $" + String.format("%.2f", totalBoxSaleAmount) + " " + "Number Of Sideline Tickets Sold: " + (noOfSidelineTicketsSold) + " " + "Sideline Total: $" + String.format("%.2f", totalSidelineSaleAmount) + " " + "Number Of Premium Tickets Sold: " + (noOfPremiumTicketsSold) + " " + "Premium Total: $" + String.format("%.2f", totalPremiumSaleAmount) + " " + "Number Of General Tickets Sold: " + (noOfGeneralTicketsSold) + " " + "General Total: $" + String.format("%.2f", totalGeneralSaleAmount) + " "; JOptionPane.showMessageDialog(null, outputStr, "Total Ticket Sales", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote