Answer to Question #26278 in C++ for red rose

Question #26278
the following if-else chain into a full C++ program using a switch statement:



#include <iostream>

using namespace std;



int main()

{

char letterGrade;



cout << "Enter the grade: ";

cin >> letterGrade;



if (letterGrade==’A’)

cout<<”The numerical grade is between 90 and 100\n”;

else if (letterGrade==’B’)

cout<<”The numerical grade is between 80 and 89.9\n”;

else if (letterGrade==’C’)

cout<<”the numerical grade is between 70 and 79.9\n”;

else if (letterGrade==’D’)

cout<<”How are you going to explain this one\n”;

else

{

cout<<”Of course I had nothing to do with my grade.\n”;

cout<<”It must have been the professor’s fault.\n”;

}



return 0;

}
1
Expert's answer
2013-03-12T11:58:42-0400
#include <iostream>

using namespace std;

int main()
{
char letterGrade;

cout << "Enter the grade: ";
cin& >> letterGrade;

switch(letterGrade)
{
case 'A':
& cout<<"The numerical grade is between 90 and 100\n";
& break;

case 'B':
& cout<<"The numerical grade is between 80 and 89.9\n";
& break;

case 'C':
& cout<<"the numerical grade is between 70 and 79.9\n";
& break;

case 'D':
& cout<<"How are you going to explain this one\n";
& break;

default:
& cout<<"Of course I had nothing to do with my grade.\n";
& cout<<"It must have been the professor's fault.\n";
}

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS