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

_Write a program to prompt the user to enter a grade between 0 and 100 _Display

ID: 3542546 • Letter: #

Question

_Write a program to prompt the user to enter a grade between 0 and 100

_Display the proper letter grade based on the number entered (A,B,C, D, F)

_If the user enters a value of less than 0, display an error message

_If the user enters a value greater than 100, ask the user if they are sure about the grade.

_If they answer y or Y allow the grade.

_If the grade entered is within 0.5 of the next letter grade, ask the user if they want to round the letter

grade up. If they answer y or Y add 0.5 to the grade before determining letter grade.

Explanation / Answer


#include<iostream>
using namespace std;
int main()
{
double grade;
char ans,response;
cout <<"Enter grade between (0 to 100) ";
cin >> grade;
cout << endl;
if(grade < 0)
cout << "Grade cant be lesss than 0" << endl;
if(grade > 100)
{
cout << "Are you sure about this grade ";
cin >> ans;
if(ans=='y' || ans=='Y')
{
cout << "Grade is A" << endl;
}
}
else if(grade > 90)
{
cout << "Grade is A" << endl;
}
else if(grade > 80)
{
if(grade+0.5 == 90)
{
cout << "Do you want to round the letter grade up";
cin >> response;
}
if(response =='y' || response =='Y')
cout << "Grade is A" << endl;
else
cout << "Grade is B" << endl;
}
else if(grade > 70)
{
if(grade+0.5 == 80)
{
cout << "Do you want to round the letter grade up";
cin >> response;
}
if(response =='y' || response =='Y')
cout << "Grade is B" << endl;
else
cout << "Grade is C" << endl;
}
else if(grade > 60)
{
if(grade+0.5 == 70)
{
cout << "Do you want to round the letter grade up";
cin >> response;
}
if(response =='y' || response =='Y')
cout << "Grade is C" << endl;
else
cout << "Grade is D" << endl;
}
else
{
cout << "Grade is F" << endl;
}

return 0;
}