Try using arrays instead of single variables, and just throw the reading code into a loop.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>I just keep gettin stuck on how to create a loop on the readline section of the code
Try something like this:
String line;
while ((line = inFile.readLine()) != null) {
// Tokenize and process
}
As for the array part, it would be considerably easier to treat each record as a complete entity rather than separate variables:
class Record {
private double[] tests;
private double average;
private String firstName;
private String lastName;
public Record(String first, String last, double[] tests);
public display();
};
Then you can create a data structure (such as an array) of Records. However, if you don't need to save a record before processing another, there's really no need to go to that kind of effort. You can just use the stream reading loop above with the code you have.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
My first guess would be a formatting issue in your input file.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401