
228 CHAPTER 5 Flow of Control,Part 1: Selection
5.5 Sequential and Nested if/else Statements
When you need the results of one if statement’s processing before you can
evaluate the next condition, you can write multiple if statements either
sequentially or nested within other if statements.
5.5.1 Sequential if/else Statements
Finding the Minimum or Maximum Values
To illustrate sequential if statements, let’s look at the problem of finding the
smallest of three numbers.
In Chapter 3, we found the smallest of three numbers using the min
method of the Math class. We first found the smaller of two numbers, then
found the smaller of that result and the third ...