#C14755. Average Student Grades
Average Student Grades
Average Student Grades
Given a JSON object representing student names and their list of grades, calculate the average grade for each student. Only valid grades, which are numeric values within the range \(0 \leq g \leq 100\), are considered. The average is computed as the arithmetic mean of these valid grades and should be rounded to the nearest integer. If a student has no valid grade or an empty list, the average should be output as null
.
The formula to compute the average is:
\(\text{Average} = \frac{\sum valid\_grades}{\text{number of valid grades}}\)
inputFormat
The input is provided as a single line on standard input in JSON format. It contains a single JSON object where each key is a student name (string) and the corresponding value is a list of grades. Grades may be integers or floating point numbers. Any grade that is non-numeric or not in the range \([0, 100]\) should be ignored.
outputFormat
Output a JSON object (to standard output) in which each key is a student name and each value is either the computed average grade (an integer, rounded to the nearest integer) or null
if no valid grades were present.
{"Alice": [88, 92, 77]}
{"Alice":86}