Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/************************************************************ * * 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions