help with loops and if else

Solved.
Last edited on
else if(courseAverage=85-92){letterGrade="B";}
What?? That's not how comparisons work.
Its wrong in some many ways, but the jist of it is that it will always evaluate true.

else if(courseAverage>85 && courseAverage<92){letterGrade="B";}
The logical operator for the idea of "or" is the double pipe symbol:

||

you can think of if else statements like:

1
2
3
4
if(this is true then)
{
true goes inside angle braces
}

if the if condition is not true then execute the else
1
2
3
4
else
{
do these things since the if was not true
}


very much like using a bool but more complicated and many times you can just use a bool instead.

or add
1
2
3
4
 else if(other conditions)
{
other conditions can go here
}

for further conditions
Last edited on
Topic archived. No new replies allowed.