Question: For C++ write a program that contains a do...while loop. the loop should continue until the user types N or n to quit. inside this

For C++ write a program that contains a do...while loop. the loop should continue until the user types N or n to quit.

inside this loop should be another loop that loops while a bool variable is FALSE

have the user enter a letter grade (a, b, c, etc). if the letter grade is invalid, the loop should notify the user and have them reenter the number. otherwise the the loop stops

inside the loop, have a switch statement.

the switch statement should set the validity of the number

the switch should output the number range for the given grade.

for example, if the user enters B, the program should output

"The number range for the grade of B is 80-89"

the program should be able to handle upper and lower case letters

This is what I have but I can not get it all to work can you help...

1 #include 2 using namespace std; 3 4 5 int main() 6 { 7 int counter = 10; 8 char quit; 9 char letterGrade; 10 bool validGrade = true; 11 12 13 14 // do while loop 15 do{ 16 cout << "Enter a letter grade" << endl; 17 cin >> letterGrade; 18 ans = letterGrade; 19 counter++; 20 21 22 validGrade = (ans != 'A'&& ans != 'a'&&ans != 'B'&& ans != 'b'&&ans != 'C'&& ans != 'c'&&ans != 'D'&& ans != 'd'&&ans != 'F'&& ans != 'f'); 23 24 while (validGrade = letterGrade){ // loop within loop 25 26 27 28 29 30 31 // switch Statement 32 switch (letterGrade){ 33 34 case 'A': 35 case 'a': 36 cout << "The number range for the grade of A is 90-100 "; 37 break; 38 case 'B': 39 case 'b': 40 cout << "The number range for the grade of B is 80-89 "; 41 break; 42 case 'C': 43 case 'c': 44 cout << "The number range for the grade of C is 70-79 "; 45 break; 46 case 'D': 47 case 'd': 48 cout << "The number range for the grade of D is 60-69 "; 49 break; 50 case 'F': 51 case 'f': 52 cout << "The number range for the grade of F is 0-59 "; 53 break; 54 55 default: 56 57 cout << "The grade you have entered is not valid please try again "; 58 59 } 60 61 } 62 63 } while(quit!='N'&&quit!='n'); //This is added to stop the loop 64 65 66 return 0; 67 68 }

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!