QUESTION 19 (The steps below are just an aid in writing the complete program) 1
ID: 3718654 • Letter: Q
Question
QUESTION 19 (The steps below are just an aid in writing the complete program) 1 a. Using a do statement, write a program to accept a grade. The program should request a grade cotinuously as long as an invalid grade is entered An invalid grade is any grade less than O or greater than 100 After a valid grade has been entered, your program should display the value of the grade entered 1.b. Modify the program written in 1.a so that the user is alerted when an invalid grade has been entered, but continue 1.c. Modify the program written in 1.b. so that it allows the user to exit the program by entering the number 1.d. Modify the program written in 1.c so that it automatically terminates after five invalid grades are entered 1.e. Add a comment at the beginning of the cpp file containing your name, course code and date Provide the cpp fle along with screenshot(s) showing the program satisfies each of the requirements Create a zip file to submit the files together Attach File Browse My Computer Browse Content ColectionBrowse DiooboExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
int invalid=0;
int grade;
do{
std::cout << "Enter a grade:";
cin>>grade;// read the grade
if(grade<0 || grade>100){// check if valid grade
cout<<"Invalid grade entered. ";
invalid++;
}else{
cout<<" Entered grade was : "<<grade<<" ";
}
if(invalid>=5){
cout<<"You entered invalid grade 5 times. Program will exit";
break;
}
}while(grade!=999);
return 0;
}