#C14451. Aggregate Students by Rounded GPA
Aggregate Students by Rounded GPA
Aggregate Students by Rounded GPA
You are given a list of students along with their respective grade point averages (GPAs). Your task is to group the students by their GPAs after rounding them to the nearest tenth. In other words, for each student with GPA \(g\), compute \(\text{round}(g, 1)\) (i.e. round \(g\) to one decimal place) and group all students with the same rounded value.
The input will first give you the number of students \(n\), followed by \(n\) lines where each line contains a student's name and their GPA. The output should display each unique rounded GPA in ascending order, followed by a colon and the list of student names (in the order they appeared in the input) that belong to that GPA group. Each group should be printed on its own line.
inputFormat
The first line contains a single integer (n) (the number of students). The next (n) lines each contain a student's name (a string without spaces) and a floating-point number (g) representing the student's GPA, separated by a space.
outputFormat
For each distinct rounded GPA (rounded to one decimal place), print a line in the format:
gpa: student1 student2 ...
The GPA groups should be printed in ascending order of the GPA.## sample
1
Alice 3.67
3.7: Alice
</p>