If Statements With Multiple conditions

Ok, I'm working on code for a project, and I need to know how to use the if statements for if/else if/else with multiple conditions. This is the info I have to code:
>= 89.5 A

79.5 – 89.49 B

69.5 – 79.49 C

59.5 – 69.49 D

<= 59.49 F

This is my code:
avg_grade = (grade1 + grade2 + grade3 + grade4 + grade5)/5;

cout <<setprecision(2)<<fixed;


cout<<"Average = "<<avg_grade<<endl;

if(avg_grade <= 59.49)
{
cout<<"Grade = F"<<endl;
}
else if(avg_grade <69.49 || avg_grade >=59.5)
{
cout<<"Grade = D"<<endl;

}
else if(avg_grade <79.49 || avg_grade >=69.5 )
{
cout<<"Grade = C"<<endl;
}
else if(avg_grade <69.49 || avg_grade >=59.5)
{
cout<<"Grade = D"<<endl;

}
else if(avg_grade <89.49 || avg_grade >=79.5)
{
cout<<"Grade = B"<<endl;
}

else
{
if(avg_grade >= 89.5)
{
cout<<"Grade = F"<<endl;
}

}



The code works, but once I get to the third condition they don't execute the court command. They just repeat the command from the second condition. Thanks in advance for any help.
Last edited on
Duplicate: http://www.cplusplus.com/forum/general/282076/

Don't double post when you already have another for the same code.

Also:
PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either
Last edited on
Topic archived. No new replies allowed.