For your application to be truly effective, it must be able to make decisions. It must be able to distinguish between two different situations and execute different code based on criteria you choose. For example, when examining user input, you can use conditional logic to alter the flow of your program, causing it to execute only those sections of code that are relevant. This allows you to create applications that respond dynamically and give the user an interactive experience. In this chapter, you learn how to apply conditional logic using variations of the if and switch statements. You also gain a better understanding of this logic through development of this chapter's game project, the Guess a Number game.
In this chapter, you learn the following:
How to test two logical conditions
How to provide for alternative courses of action
How to embed conditional statements to create more complicated conditional logic tests
How to rest multiple conditions against a single value