Chapter Review
In this chapter we saw how programs can make decisions. You saw that programs use “if statements” to make decisions. An “if statement” allows the program to check the value of something and perform a task, if the value is what is expected.
You can also use “else” statements in conjunction with “if” statements. These “else” statements specify an action to take if the “if” statement failed to execute. Using these “else” statements, you can create long if/else ladders. These ladders allow your program to do many comparisons in a row.
If you are comparing a numeric value you can use a switch/case in place of the if/else ladder. It is important to remember that switch/case statements cannot be used on strings. If you want to compare a string to many different values, you must use an if/else ladder. You can also place a “default” statement at the end of the switch/case. The “default” statement will be executed if none of the cases match.




