Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite the following if-else chain using a switch statement: //Variable Declara

ID: 3558175 • Letter: R

Question

Rewrite the following if-else chain using a switch statement:

//Variable Declaration/Initialization

char letGrad = 'B';

if (letGrad == 'A')

cout << "The numerical grade is between 90 and 100" << endl;

else if (letGrad == 'B')

cout << "The numerical grade is between 80 and 89.95" << endl;

else if (letGrad == 'C')

cout << "The numerical grade is between 70 and 79.95" << endl;

else if (letGrad == 'D')

cout << "The numerical grade is between 60 and 69.95" << endl;

else cout << "F is grade" << endl;

Explanation / Answer

char letGrad='B';
switch(letGrad)
{
   case 'A':
   cout << "The numerical grade is between 90 and 100"
   break;

   case 'B':
   cout << "The numerical grade is between 80 and 89.95"
   break;

   case 'C':
   cout << "The numerical grade is between 70 and 79.95"
   break;

   case 'D':
   cout << "The numerical grade is between 60 and 69.95"
   break;
  
   default:
   cout << "F is grade"
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote