1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
int main ()
{// Declarations
char letter= 'A','B', 'C','D','E','F';
char ch='A';
int num=4;
cout << "Enter a single character:";
cin>>letter;
cout<< "A grade letter of __ is satisfactory" << endl;
cin>> A,B,C;
cout<< "A grade letter of D is borderline" < <endl;
cin >> D;
cout << "A grade letter of F is failing" << endl;
cin >> F;
cout << "invalid letter grade" << endl;
cin >> E, num;
cout<< endl;
if (ch='A','B','C')
{
cout << "A grade letter of ___ is satisfactory" << endl;
}
else (ch='E') && (num=4)
{
cout << "Invalid letter grade" << endl;
}
if (ch='D')
{
cout << "A grade letter of D is borderline" << endl;
}
if (ch='F')
{
cout << "A grade letter of F is failing" << endl;
}
|
Line 3: You cannot do this. Basically, right here you're trying to define 7 values to 1 variable which will just cause a ton of errors.
Line 4: You declare this ch, and set it equal to 'A', then later try to do comparisons like the value has changed, even though it hasn't. Also, having two different char variables is superfluous, so I would suggest removing one.
Line 5: I don't know why you have an integer at all, it just seems useless.
Lines 8-16: Get rid of all this.
Line 21: You have the right idea here, but that's not have comparisons work in C++. I think you want "if ch is equal to a or b or c", which would be written,
if (ch =='A' || ch == 'B' || ch == 'C')
Notice that when doing equals comparisons, you use == instead of =. Also, || is the or operator, and each comparison must be separated.
Line 24: Instead of ___ use << ch <<. Close the string on either side.
Line 27: else cannot be followed by conditions. If you wanted conditions, use else if.
Also, move this to the very end.
Make sure you close main with a }.