Created
October 17, 2012 12:51
-
-
Save juanfal/3905354 to your computer and use it in GitHub Desktop.
switch example through student grades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 03.grades.cpp | |
// Switch example through student grades | |
#include <iostream> | |
#include <cctype> | |
using namespace std; | |
int main( ) | |
{ | |
char grade; | |
cout << "Enter your control grade (A, B, C, D, E or F): "; | |
cin >> grade; | |
switch (toupper(grade)) | |
{ | |
case 'A': | |
cout << "Excellent. " | |
<< "You need not take the final.\n"; | |
break; | |
case 'B': | |
cout << "Very good. "; | |
grade = 'A'; | |
cout << "Your midterm grade is now " | |
<< grade << endl; | |
break; | |
case 'C': | |
cout << "Passing.\n"; | |
break; | |
case 'D': | |
case 'F': | |
cout << "Not good. " | |
<< "Go study.\n"; | |
break; | |
default: | |
cout << "That is not a possible grade.\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment