#C12625. Convert Numerical Grades to Letter Grades
Convert Numerical Grades to Letter Grades
Convert Numerical Grades to Letter Grades
You are given a list of numerical grades and you need to convert each grade to its corresponding letter grade based on the following scale:
- \( A: 90 \leq grade \leq 100 \)
- \( B: 80 \leq grade \leq 89 \)
- \( C: 70 \leq grade \leq 79 \)
- \( D: 60 \leq grade \leq 69 \)
- \( F: 0 \leq grade \leq 59 \)
If any input grade is not in the range \( 0 \) to \( 100 \), your program must output the exact error message: "Grade out of valid range: 0-100". The program should read from standard input and print to standard output.
inputFormat
The first line of input contains a single integer \( n \), the number of grades. The second line contains \( n \) space-separated integers which represent the grades.
outputFormat
If all the grades are within the valid range, output the corresponding letter grades separated by a single space. If any grade is out of the valid range [0, 100], output Grade out of valid range: 0-100
.
5
85 92 78 60 45
B A C D F
</p>