← Back to Streams
Question 594
Grade Book Report
Grade Book Report
Write a functionvoid gradeReport(const string& filename). Each line of the file holds a student's name followed by three integer scores, separated by single spaces: Ann 80 85 90 Bob 70 76 82 For every student, in file order, print the name, a colon, a space and the average of that student's three scores with exactly one digit after the decimal point. After all students, printClass average:followed by the average of the per-student averages, also with one decimal place. The output for the file above is exactly what is shown in Expected Output. If the file cannot be opened, or it opens but contains no students, print the single lineNo dataand nothing else. One test passesmissing_dir/grades.txtand another passes an empty file. Do NOT write a main function.
Expected Output:
Ann: 85.0 Bob: 76.0 Class average: 80.5 No data No data
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Streamsifstream
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.