#K12211. Letter Grade Calculation
Letter Grade Calculation
Letter Grade Calculation
You are given a list of students with their names and a set of grades. Your task is to calculate the average grade for each student and then assign a letter grade based on the following criteria:
- A: \(\text{average} \ge 90\)
- B: \(80 \le \text{average} < 90\)
- C: \(70 \le \text{average} < 80\)
- D: \(60 \le \text{average} < 70\)
- F: \(\text{average} < 60\)
The input is read from standard input and the results should be printed on standard output. For each student, output their name and corresponding letter grade on a new line, separated by a space.
inputFormat
The input is provided via standard input (stdin) and has the following format:
n name_1 grade1 grade2 ... gradeK1 name_2 grade1 grade2 ... gradeK2 ... name_n grade1 grade2 ... gradeKn
Where:
- n: an integer representing the number of students.
- For each student, the first line is a string representing the student's name.
- The second line contains one or more integers representing the grades of the student, separated by spaces.
outputFormat
For each student, output a single line with the student's name and their corresponding letter grade separated by a space. The output must be written to standard output (stdout).
name grade## sample
5
Alice
95 85 92
Bob
70 76 68 72
Charlie
88 82 84
Diana
60 58 64
Eve
45 50 48
Alice A
Bob C
Charlie B
Diana D
Eve F
</p>