diff --git a/letter-grade.c b/letter-grade.c index ae6f968..7123716 100644 --- a/letter-grade.c +++ b/letter-grade.c @@ -7,17 +7,27 @@ int main() { if ((input >= 0) && (input <= 100)) { char letter; - if ((input/10) >= 9) { - letter = 'A'; - } else if ((input/10) >= 8) { - letter = 'B'; - } else if ((input/10) >= 7) { - letter = 'C'; - } else if ((input/10) >= 6) { - letter = 'D'; - } else { - letter = 'F'; + int inputRange = input/10; + + switch(inputRange) { + case 10: + case 9: + letter = 'A'; + break; + case 8: + letter = 'B'; + break; + case 7: + letter = 'C'; + break; + case 6: + letter = 'D'; + break; + case 5: + default: + letter = 'F'; } + printf("Your letter grade is %c\n", letter); } else { printf("ERROR: Input must be no more than 100 and no less than 0\n");