Because the first true condition wins, the order of the branches changes the result. For overlapping ranges, put the most specific / strictest condition first, or a looser one will catch a value it shouldn't.
// correct: strict first if (s >= 90) grade = "A"; else if (s >= 80) grade = "B"; // wrong order: 95 would match >= 80 first and become "B" if (s >= 80) grade = "B"; else if (s >= 90) grade = "A"; // never reached for 95
▶ Try it: these branches are in the wrong order. Run it — 95 prints B, not A. Now swap the two branches so s >= 90 is checked first, and run again — now it prints A.
B
A
s >= 90
In the wrong-order version above, what grade does s = 95 get?
s = 95
For if (mph < 30) "slow"; else if (mph <= 60) "ok"; else "fast";, what does mph = 30 give?
if (mph < 30) "slow"; else if (mph <= 60) "ok"; else "fast";
mph = 30
For the same speed chain, type what mph = 75 gives:
mph = 75
True or false?
Put these branches in the correct order so each score gets the right grade (strictest first).