Question: /************************************************************ * * FileName: caseswitch.cpp * Author: Guili Liu * Purpose: Demonstrate how to use Switch Statemenet. * **************************************************************/ #include using namespace std; int main()

/************************************************************ * * FileName: caseswitch.cpp * Author: Guili Liu * Purpose: Demonstrate how to use Switch Statemenet. * **************************************************************/ #include  using namespace std; int main() { char grade; //Fill in this for loop so it will repeat six times for ( ; ; ) { cout << "Please enter a character grade (A, B, C, D, or F): "; cin >> grade; switch (grade) { case 'A': cout << "Great work. " << endl; break; // Add a case for 'B' that prints "Good work." case 'C': cout << "Passing work. " << endl; break; case 'D': case 'F': cout << "Unsatisfictory work. " << endl; cout << "See your instructor." << endl; break; // Add a default that prints // grade << " is not a legal grade." } //end of switch statement } //end of for loop return 0; } // end program 

Get a copy of the caseswitch.cpp.

The purpose of the program is to demonstrate how to use Switch statement.

Complete the for loop so that the program will ask the user for 6 input grades.

Compile and run this C++ program. Use input value A, B, C, D, E, and F.

Notice there is no output for B and E. Add cases for them.

B is "Good Work." Add a case for 'B'.

E is not a legal grade. Add a default case for all unrecognized grades that prints grade << " is not a legal grade.".

---------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!