i made a program that gives you a letter grade and average when you enter a number from 0 to 100. I'm missing one piece where the user inputs a number outside of 0 to 100. the output is suppose to look like this
Example output 1 (invalid input, input is in bolded italics):
GPA Conversion
- - - - - - -
Enter your grade: -10.2
You have not entered an grade between 0 and 100. Ending program.
every code i tried doesn't result in what im suppose to get above if i put an invalid number.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
float grade;
cout.precision(2);
cout << "GPA Conversion" << endl;
cout << "--------------" << endl;
cout << "Enter your grade: ";
cin >> grade;
cout << endl;
if ( grade <=100 && grade >=96)
cout << "You will receive a letter grade of A with a 4.00 GPA.";
if ( grade <=95 && grade >=90)
cout << "You will receive a letter grade of A- with a 3.70 GPA.";
if ( grade <=89 && grade >=87)
cout << "You will receive a letter grade of B+ with a 3.30 GPA.";
if ( grade <=86 && grade >=84)
cout << "You will receive a letter grade of B with a 3.00 GPA.";
if ( grade <=83 && grade >=80)
cout << "You will receive a letter grade of B- with a 2.70 GPA.";
if ( grade <=79 && grade >=77)
cout << "You will receive a letter grade of C+ with a 2.30 GPA.";
if ( grade <=76 && grade >=74)
cout << "You will receive a letter grade of C with a 2.00 GPA.";
if ( grade <=73 && grade >=70)
cout << "You will receive a letter grade of C- with a 1.70 GPA.";
if ( grade <=69 && grade >=67)
cout << "You will receive a letter grade of D+ with a 1.30 GPA.";
if ( grade <=66 && grade >=64)
cout << "You will receive a letter grade of D with a 1.00 GPA.";
if ( grade <=63 && grade >=60)
cout << "You will receive a letter grade of D- with a 0.70 GPA.";
if ( grade <=59 && grade >=0)
cout << "You will receive a letter grade of F with a 0.00 GPA.";
return 0;
}