diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-06 11:26:44 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-06 11:26:44 -0500 |
| commit | 97a693d996c79fb2a008b19750d8bb45512e01a2 (patch) | |
| tree | 6df17bfe7de7c59f7b1083828d71a91e61fae9fa /switchgrade.c | |
| download | engr0016-master.tar.gz engr0016-master.tar.bz2 engr0016-master.zip | |
Diffstat (limited to 'switchgrade.c')
| -rw-r--r-- | switchgrade.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/switchgrade.c b/switchgrade.c new file mode 100644 index 0000000..b22cd66 --- /dev/null +++ b/switchgrade.c @@ -0,0 +1,42 @@ +/*File: switchgrade.c +This program reads a grade from the screen and prints the corresponding numerical value of the score.*/ + +#include <stdio.h> + +int main() +{ + char grade; + double score; + + printf("Enter a grade [A,B,C,D,F]: "); + scanf(" %c",&grade); + + //Force all characters to be uppercase + if(grade>=97) + { + grade = grade-32; + } + + switch(grade) + { + case 'A': + score += 1.0; + case 'B': + score += 1.0; + case 'C': + score += 1.0; + case 'D': + score += 1.0; + case 'F': + break; + default: + score = -1; + printf("Invalid grade %c\n",grade); + break; + } + if(score != -1) + { + printf("The score for the grade %c is %.2f\n",grade,score); + } + return 0; +} |
