Hey guys, im still struggling with this homework /:< so i have the intro but when the program reads the file i can only get it to read each integers separately instead of making an array of 3. it should print out something like this:
day 1: 200 500 800
day 2: 300 400 700
day 3: 100 0 500
day 4: 1700 400 600
day 5: 300 100 400
day 6: 800 900 600
day 7: 1000 300 700
but ends up doing this...
day 1: 200
day 2: 500
day 3: 800
...
day 20: 300
day 21: 700
this is the inFile part of the code:
---------------------------------------------------------------------------------
while(in.hasNext())
try
{
int value = Integer.parseInt(in.next());
System.out.println("Day " + lineNumber + ": "+ value);
lineNumber++;
}
catch (NumberFormatException e)
{
System.out.println("Input was not a number");
in.nextLine();
}
---------------------------------------------------------------------------------
My question is, how can i make an array that can print the first three integers then make another array that would read the next three and so on... im thinking of doing a for loop but i have no idea how to set it up /: anyone?