Chapter 10
Which Way Did He Go?
IN THIS CHAPTER
Untangling complicated conditions
Writing cool conditional code
Intertwining your if statements
It’s tax time again. At the moment, I’m working on Form 12432-89B. Here’s what it says:
If you’re married with fewer than three children, and your income is higher than the EIQ (Estimated Income Quota), or if you’re single and living in a non-residential area (as defined by Section 10, Part iii of the Uniform Zoning Act), and you’re either self-employed as an LLC (Limited Liability Company) or you qualify for veterans’ benefits, then skip Steps 3 and 4 or 4, 5, and 6, depending on your answers to Questions 2a and 3d.
No wonder I have no time to write! I’m too busy interpreting these tax forms.
Anyway, this chapter deals with the potential complexity of if
statements. This chapter has nothing as complex as Form 12432-89B, but if you ever encounter something that complicated, you’ll be ready for it.
Forming Bigger and Better Conditions
In Listing 9-2 (refer to Chapter 9), the code chooses a course of action based on one call to the Random
class’s nextInt
method. That’s fine for the electronic oracle program described in Chapter 9, but what ...
Get Beginning Programming with Java For Dummies, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.