August 2013
Beginner
352 pages
8h 50m
English
case for the switch StatementIn This Chapter
• Testing multiple cases with switch
• Combining break with switch
The if statement is great for simple testing of data, especially if your data tests have only two or three possibilities. You can use if to test for more than two values, but if you do, you have to nest several if statements inside one another, and that can get confusing and hard to maintain.
Consider for a moment how you execute code based on a user’s response to a menu. A menu is a list of options from which to select, such as this one:
What do you want to do?1. Add New Contact2. Edit Existing Contact3. Call Contact4. Text Contact5. Delete Contact6. Quit the ProgramWhat is your choice?
Note
When you create menus ...
Read now
Unlock full access