43 lines
1021 B
C
43 lines
1021 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
printf("Please enter a whole number percentage (0-100): ");
|
|
char inputText[4];
|
|
fgets(inputText, 4, stdin);
|
|
printf("inputText: %s\n", inputText);
|
|
long int input;
|
|
input = strtol(inputText, NULL, 0);
|
|
printf("input: %li\n", input);
|
|
|
|
if ((input >= 0) && (input <= 100)) {
|
|
char letter;
|
|
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);
|
|
return 0;
|
|
} else {
|
|
printf("ERROR: Input must be no more than 100 and no less than 0\n");
|
|
return 1;
|
|
}
|
|
}
|