Help figuring out equation.

• 10-05-2007
gator6688
Help figuring out equation.
How could I write these so that they would work?The "A" and the "F" work but the other 3 don't.

Code:

```cout << "Letter Grades" <<endl;         for (int i = 0; i < MAXGRADES; i++)         {                 if (grade[i]>89)                         cout<<"A"<<grade[i];                 if (90>grade[i]>79)                         cout<<"B"<<grade[i];                 if (80>grade[i]>69)                         cout<<"C"<<grade[i];                 if (70>grade[i]>59)                         cout<<"D"<<grade[i];                 if (grade[i]<60)                         cout<<"F"<<grade[i];         }```
• 10-05-2007
MacGyver
Use &&, which performs a logical AND on two arguments.
• 10-05-2007
brewbuck
The construct:

Code:

`a > b > c`
Does not do what you think it does. Instead, use:

Code:

`a > b && b > c`
• 10-05-2007
gator6688
OK. Thanks. I should have known that!
• 10-05-2007
hk_mp5kpdw
This is all you should need:
Code:

```cout << "Letter Grades" <<endl; for (int i = 0; i < MAXGRADES; i++) {     if (grade[i]>89)         cout<<"A"<<grade[i];     else if (grade[i]>79)         cout<<"B"<<grade[i];     else if (grade[i]>69)         cout<<"C"<<grade[i];     else if (grade[i]>59)         cout<<"D"<<grade[i];     else         cout<<"F"<<grade[i]; }```