ChapterÂ 3.Â Adding Logic and Control to Your Programs
Making Programs React Intelligently
Our lives are filled with choices: âWhat should I wear today?â, âWhat should I eat for lunch?â, âWhat should I do Friday night?â, and so on. Many choices you make depend on the situation. For example, say you decide you want to go to the movies on Friday night. Youâll probably ask yourself a bunch of questions like âAre there any good movies playing?â, âIs there a movie starting at the right time?â, âDo I have enough money to go to the movies (and buy a $17 bag of popcorn)?â
Suppose there is a movie thatâs playing at just the time you want to go. You then ask yourself a simple question: âDo I have enough money?â If the answer is yes, youâll head out to the movie. If the answer is no, you wonât go. But on another Friday, you do have enough money, so you go to the movies. This scenario is just a simple example of how the circumstances around us affect the decisions we make.