This number line, and the two rows of inequalities below it, show how the textbook derives the tests in the succession of else-if clauses. |-----------|---------------|---------------|---------------|--------------- Richter scale 0 4.5 6.0 7.0 8.0 default r >= 4.5 r >= 6.0 r >= 7.0 r >= 8.0 (working right-to-left) r < 4.5 r < 6.0 r < 7.0 r < 8.0 default (working left-to-right) Here is the number line for the textbook's 24-hour clock example. night morning afternoon evening |--------------|--------------|--------------|--------------| hours 0 6 12 18 hour < 6 hour < 12 hour < 18 default (working left-to-right) default hour >= 6 hour >= 12 hour >= 18 (working right-to-left) // working left-to-right // working right-to-left if (hour < 6) if (hour >= 18) { { time = "night"; time = "evening"; } } else if (hour < 12) else if (hour >= 12) { { time = "morning"; time = "afternoon"; } } else if (hour < 18) else if (hour >= 6) { { time = "afternoon"; time = "morning"; } } else else { { time = "evening"; time = "night"; } }