Making the Grade
Time limit1sMemory limit128 MB
Compute each student's average after dropping the lowest test if more than two tests exist, then derive class mean and standard deviation, apply bonus and attendance letter-grade rules, and print the class GPA.
- Level
Medium4 of 10
- Topics
- Implementation, Math, Simulation, Sorting
- Solved
- No attempts yet
Problem
Mr. Chips uses a simple grading scheme that can be computed automatically. Write a program that reads his students' test grades, bonus points, and attendance records, computes each student's grade, and outputs the class's average grade point.
Mr. Chips grades as follows. Every test is out of 100 points, and every test grade is an integer between 0 and 100. If more than 2 tests have been given, he drops each student's lowest test grade before computing that student's average. After computing the student averages, he computes the overall class mean and standard deviation (sd).
The letter-grade cutoffs are based on the class mean and sd:
- an average one sd above the mean is an A;
- an average the mean but one sd above the mean is a B;
- an average one sd below the mean but the mean is a C;
- an average one sd below the mean is a D.
For every two bonus points a student has accrued, Mr. Chips raises that student's computed average by 3 percentage points. So a student with 1 bonus point gets no boost, a student with 4 or 5 bonus points gets +6 points, and so on (the boost is ). Bonus boosts are applied to the averages after the grade cutoffs have been determined.
Finally, attendance adjusts the letter grade. For every 4 absences a student loses one letter grade (A→B, B→C, C→D, D→F); for example, 9 absences cost two letter grades. A student can never fall below F. A student with perfect attendance (0 absences) gains one letter grade, but can never rise above A.
Throughout his computations, Mr. Chips always rounds results to the nearest tenth.
In summary, for each class Mr. Chips drops each student's lowest test grade if more than 2 tests were given, computes each student's average, computes the class mean and sd, applies the bonus boosts to the averages, determines each student's letter grade from the cutoffs, and finally adjusts the letter grades for attendance.
The average grade point of a class uses 4 points for each A, 3 for each B, 2 for each C, 1 for each D, and 0 for each F. The class's total points are summed and divided by the number of students (always at least 2).
The standard deviation sd of a list of numbers is
where is the mean of the list. If the computed standard deviation is less than 1, Mr. Chips uses 1 in its place for the grade calculation.
Worked example: suppose Mr. Chips has 5 students and has given 3 tests. The table below shows each student's test scores, bonus points, and absences, together with the computed average (lowest test dropped), the adjusted average (with bonus), the unadjusted grade, and the adjusted grade (with attendance). The mean and sd used for the cutoffs are 69.0 and 20.1, so, for instance, an unadjusted B requires an average and .
The average grade point for this class is 2.2.
Input
The first line contains an integer (): the number of classes.
Each class is described as follows. The first line contains two integers and , where is the number of students () and is the number of tests taken (). The next lines each describe one student: first the student's test scores (integers between 0 and 100 inclusive), then the student's bonus points, then the student's number of absences.
Output
Output one line for each class: that class's average grade point, rounded to the nearest tenth.