#K60802. Compute Student Averages

    ID: 31167 Type: Default 1000ms 256MiB

Compute Student Averages

Compute Student Averages

You are given multiple lines of input where each line contains a student's name and a grade. The input terminates with a line containing STOP. You are required to compute the arithmetic mean of all valid grades for each student and then output each student's name along with their average grade formatted to two decimal places.

A grade is considered valid if it is an integer with \(0 \leq grade \leq 100\). Invalid grades should be ignored. The final output should list the students in alphabetical order.

inputFormat

Input is provided via standard input (stdin). Each line contains a student's name followed by a grade separated by space. Input ends when a line containing exactly "STOP" is encountered. Only grades from 0 to 100 (inclusive) are valid. Ignore any line that does not meet these requirements.

outputFormat

For each student with at least one valid grade, print a separate line to standard output (stdout) with the student's name and the calculated average grade formatted to two decimal places. The student lines must be in alphabetical order according to the student's name.## sample

John 80
Jane 85
John 90
Jane 95
STOP
Jane 90.00

John 85.00

</p>