//
#include "stdafx.h"
//DISPLAY 3.4 The Importance of Braces
//Illustrates the importance of using braces in if-else statements.
#include
using namespace std;
enum month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sept, Oct, Nov, Dec};
//Program to illustrate the switch statement.
#include
using namespace std;
int main( )
{
month myMonth;
myMonth = Jan;
if (myMonth == Mar)
char grade;
cout << "Enter your midterm grade and press Return: ";
cin >> grade;
if (grade == 'A')
{
cout << "Excellent. "
<< "You need not take the final.\n";
}
else if (grade == 'B')
{
cout << "Very good. ";
grade = 'A';
cout << "Your midterm grade is now "
<< grade << endl;
}
else if (grade == 'C')
{
}
else if ()
{
}
else
{
}
switch (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";
}
cout << "End of program.\n";
return 0;
}
No comments:
Post a Comment