how to make if statement in this condition

Example: Enter a letter grade: a Grade range is 90 – 100
Enter a letter grade: B Grade range is 80 – 89 << this is my instruction

here is my code

#include <iostream>
#include <iomanip>

using namespace std;

int main()

{
char Grade, A, a, b, B;
cout<<setw(5)<< "Grade" <<setw(15) << "Range" <<setw(15) << "Grade" <<setw(15) << "Range" <<endl;
cout<<setw(5)<< "A" <<setw(15) << "90 - 100" <<setw(15) << "D" <<setw(15) << "60 - 69" << endl;
cout<<setw(5)<< "B" <<setw(15) << "80 - 89" <<setw(15) << "F" <<setw(15) << "50 - 59" << endl;
cout<<setw(5)<< "C" <<setw(15) << "70 - 79"<<setw(15)<< "" << setw(15) << "" <<endl;
cout << "Enter a letter grade: ";
cin >> Grade;
if (Grade==a && Grade==A)

{ cout << "Grade range is 90 - 100 " << endl;
}
else if (Grade==b && Grade==B)

{cout << "Grade range is 80- 89 " << endl;
}
else
{
cout << "Invalid grade" << endl;
}
return 0;
}

showing the invalid grade at output
Last edited on
Are you trying to write your own sqrt function or are you trying to use sqrt because if it’s the second one then just include <cmath> in the file.
This clause

5 sqrt(3)

is a problem. There's no multiplication operator, and it isn't implied in C++ as it is in math.

5 * sqrt(3)

That would do it.
Topic archived. No new replies allowed.