Practice

Highest Score in a Results File

MEDIUMFile Handling8 marks
File I/O questionresults.txt is pre-loaded for you during grading.

The file results.txt stores student records as pairs of lines: name, then integer mark, repeating to the end of the file. Output the name of the student with the highest mark and their mark on the next line. If marks tie, keep the student who appears first in the file.

Input: None (data is already in the file). Output: Name, then mark.

Example:

Output: Ben
        88
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Middle student highest
results.txt
Amal
71
Ben
88
Chen
79
Expected: Ben 88
Test 2: First student highest
results.txt
Amal
95
Ben
80
Chen
90
Expected: Amal 95