Hello, I've been going over this for a couple of days now. I was able to get the program to do the other aspects that's required except for one. I need it to read the file, "students.txt" and output on the console the highest overall grade average. Any help would be greatly appreciated.
Below is taken from, "students.txt"
Einstein Albert 80 95 85.5 80 95
Franklin Ben 70 75.5 80 82 90
Edison Tom 70 80 75.5 60 40
Tesla Nick 75 75.5 80 90 80
Dijkstra Ed 92 80 70.5 60 85
Your program is a good start, but only reads the file twice.
Testing for "eof" does not work the way you might think. By the time you check for "eof" you have already read past "eof", the "infile" stream has failed and you will be processing information from the last read. It is kind of pointless though because you only read two lines, but process one, so the chances of reaching "eof" are small.
The second if statement at line 42 really does nothing but read the file nothing is processed from the read. What would work better is something like this for a start
1 2 3 4 5 6 7 8
while (infile>>LastName) // <--- Corrects the problem with eof and fails when it tries to read past eof.
{
infile >> FirstName;
infile >> grade1;
...
// other code to process the grades.
}
My question is do you want the highest overall grade average for each line or the entire file? It sounds like the entire file which will take some more work.
Thank you for the reply. I'm not sure exactly so I've just been trying to get an average of one line which would be Einstein Albert 80 95 85.5 80 95. I'm trying to fit it in the program, but haven't had any luck. I think my mind has finally fried.