yes, math does not work in code, you must be TOTALLY explicit.
if(avg_grade <79.5 >=89.5)
should be
if(avg_grade <79.5 || avg_grade >=89.5)
however this is just a fix to your SYNTAX.
logically, you want to work in absolutes (doing less tests, each test costs time in the CPU and bloats the code).
so thinking about this..
if its < 59.5 its an f.
if its < 69.5, its a d, and you already handled f.
that^^ is what the ELSE word is for.
so..
1 2 3 4 5 6
|
if(avg_grade < 59.5)
cout... etc
else if(avg < 69.5)
cout ...
else if(... and so on
| |
see how stringing them carefully avoids having to test both ends, because you already knew some of that info and can exploit your understanding of the values to do less work? The final test does not even need a condition, its just else cout A