We have a file with data in the following form:
FirstName LastName Ex1 Ex2 Ex3 Ex4 Ex5 Ex6 Ex7
The program asks the person at the keyboard which exercise s/he is interested (1, 2, etc.). The program must then display the name of the student who had the highest score on that exercise. If there is a tie, the program should display the name of the first student with the highest score.
Here is part of the program:
cout << "Which exercise (1-7)
do you want? ";
cin >> exNumber;
inFile >> first >> last;
bestSoFar = 0;
bestStudent = "Nobody";
while ( !inFile.eof())
{
Skip (inFile,
exNumber);
inFile >> aScore;
// Work on finding highest score
here
inFile >> first
>> last;
}
cout << "The student with
the best score on exercise "
<< exNumber << " was " << bestStudent << endl;
Today's exercise is to work collectively
to write the Skip function and to fill in statements at the comment to
find the student with the highest score. The Skip function should
discard all exercise scores that come before the one specified by the person
at the keyboard so that the statement (inFile
>> aScore;) reads the correct exercise
score.