I need to write a code that takes a percentage and converts it into a letter grade. The problem is that I'm not allowed to use if statements.
85-100 -> A
75-84 -> B
65-74 -> C
55-64 -> D
0-54 -> F
One attempt I made was changing the numbers to their ASCII code but the 15 percent range for A and the D to F makes the method not work.
A = 65; B = 66; C = 67; D = 68; F = 70
letterGrade = 69 - (int)(percentage / 10 - 4.5);
Works from 94 to 55.
Edited 4 Years Ago by Mxous: typo