ANYWHO.
I have a java project that requires me to read from a data file and processing the data into an array... I finally got that to work, and it reads all the data from the file...
The part I am having serious issues with is taking the data from that file, and creating methods to "analyze" that data. We are given a concert.dat file that includes information such as: the name of the concert (string), the seating level (int), how many tickets (int), and the total ticket price per ticket (double). Now what I need to do with that, is put the data together (since some have repeat concerts within the file) and then create methods to get the average ticket price for each concert alike, gross sales, minimum ticket prices, max ticket prices, etc.
I honestly don't know where to go from here... any advice would be so much appreciated... thanks.
Here's the code I have thus far of reading the data into an array:
public void readFile() throws Exception
{
try
{
Scanner inFile = new Scanner(new File("concert1.dat"));
while (inFile.hasNext())
{
for (int i = 0; i < concertSales.length; i++)
{
for (int j = 0; j < concertSales[i].length; j++);
{
concert[i] = inFile.next();
ticketType[i] = Integer.parseInt(inFile.next());
numTix[i] = Integer.parseInt(inFile.next());
seatPrices[i] = Double.parseDouble(inFile.next());
}
System.out.println(concert[i] + " " + ticketType[i] + " " +
numTix[i] + " " + seatPrices[i] );
i++;
}
}
inFile.close();
}
catch (FileNotFoundException exception)
{
System.out.println("File not found");
}
catch (ArrayIndexOutOfBoundsException AIOOBexception)
{
System.out.println("Array Index is out of bounds");
}
catch (IllegalArgumentException IAexception)
{
System.out.println("Divide by zero error");
}
}

New Topic/Question
Reply



MultiQuote





|