I also noticed someone else had already posted this same program problem but the replies didn't help my specific problems

The assignment is :

The manage of a football team 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, the data is stored in a file in the following form:

ticket price numberOfTicketsSold

sample data

250 5750

100 28000

50 35750

25 18750

The first line indicates that the box ticket price is $250 and that 5,570 tickets were sold at that price.

Output a table that shows the number of tickets sold and the sales amount for each ticket type followed by a total line showing the overall number of tickets sold and overall sales amount.

I have constantly been looking at examples in my book but I dont understand how to do this inputing a file. My file with the sample data in it is called ticketSales.dat

I asked the user to input data but maybe im not supposed to do that because I'm supposed to use the file? But I dont know how?

This is my code:

import javax.swing.JOptionPane; import java.io.*; public class TicketSales { public static void main(String[] args) { String inputStr; String outputStr; int noOfTicketsSoldBox; int noOfTicketsSoldSideline; int noOfTicketsSoldPremium; int noOfTicketsSoldGeneral; double totalSaleAmountBox; double totalSaleAmountSideline; double totalSaleAmountPremium; double totalSaleAmountGeneral; int totalTicketsSold; double totalSalesAmount; Scanner input = new Scanner("ticketSales.dat"); inputStr = JOptionPane. showInputDialog ("Please enter the total number of tickets sold for Box Seat Admission"); noOfTicketsSoldBox= Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Please enter the total number of tickets sold for Sideline Seat Admission"); noOfTicketsSoldSideline = Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Please enter the total number of tickets sold for Premium Seat Admission") ; noOfTicketsSoldPremium = Integer.parseInt(inputStr); inputStr = JOptionPane. showInputDialog ("Please enter the total number of tickets sold for General Admission"); noOfTicketsSoldGeneral = Integer.parseInt(inputStr); totalSaleAmountBox = noOfTicketsSoldBox * 250; totalSaleAmountSideline = noOfTicketsSoldSideline * 100; totalSaleAmountPremium = noOfTicketsSoldPremium * 50; totalSaleAmountGeneral = noOf icketsSoldGeneral * 25; totalTicketsSold = noOfTicketsSoldBox + noOfTicketsSoldSideline + noOfTicketsSoldPremium + noOfTicketsSoldGeneral; totalSalesAmount = totalSaleAmountBox + totalSaleAmountSideline + totalSaleAmountPremium + totalSaleAmountGeneral; outputStr = "Number Of Box Tickets Sold: " + (noOfBoxTicketsSold) + "\n" + "Box Total: $" + String.format("%.2f", totalBoxSaleAmount) + "\n" + "Number Of Sideline Tickets Sold: " + (noOfSidelineTicketsSold) + "\n" + "Sideline Total: $" + String.format("%.2f", totalSidelineSaleAmount) + "\n" + "Number Of Premium Tickets Sold: " + (noOfPremiumTicketsSold) + "\n" + "Premium Total: $" + String.format("%.2f", totalPremiumSaleAmount) + "\n" + "Number Of General Tickets Sold: " + (noOfGeneralTicketsSold) + "\n" + "General Total: $" + String.format("%.2f", totalGeneralSaleAmount) + "\n"; + "Number Of Total Tickets Sold: " + (totalTicketsSold) + "\n" + "Total Sales Amount: $" + String.format("%.2f", totalSalesAmount) + "\n"; JOptionPane.showMessageDialog(null, outputStr, "Football Ticket Sales", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }

When I have tried to put it in my command prompt the error reads :

TicketSales.java:72:not a statement

+ String.format("%.2f", totalSalesAmount) + "\n";

^

1 error

Even though theres only one error I think I'm not doing the program as assigned!

I am so confused so if anyone could help me with my problem it would be extremely appreciated!!!

Thanks!