Quote:
Originally Posted by DewMan
The simplest thing would be to reverse your logic.
Check for the lowest value first, and the highest value last. Your value will get updated at each intermediate step that the check is valid.
if (score > 60)
grade = d
if(score > 70)
grade = c
if(score > 80)
grade = b
if(score > 90)
grade = a
|
This is extremely bad programming because you are testing score 4 times no matter what even when at times it would only need to be tested once.