ptg7068951
Summary 91
Run the program several times to see how it keeps up with the clock.
Summary
Now that you can use conditional statements, the overall intelligence of
your Java programs has improved greatly. Your programs can evaluate
information and use it to react differently in different situations, even if
information changes as the program is running. They can decide between
two or more alternatives based on specific conditions.
Programming a computer forces you to break a task down into a logical set
of steps to undertake and decisions that must be made. Using the ifstate-
ment and other conditionals in programming also promotes a type of logi-
cal thinking that can reap benefits in other aspects of your life:
. “Ifhe is elected president in November, I will seek a Cabinet posi-
tion, elseI will move to Canada.”
. “Ifmy blind date is attractive, I’ll pay for dinner at an expensive
restaurant, elsewe will go to Pizza Hut.”
. “IfI violate my probation, the only team that will draft me is the
Philadelphia Eagles.”
FIGURE 7.3
The output of the Clockprogram.