Chapter 3: Selection Structures: Making Decisions
Case-type Statements Case or Switch statements can be used to more easily code multiple alternative If’s Use the special or keyword Case Use Select to start the Case statement Specify the expression to be evaluated List each possible value of the expression and what to do if that is that value is the true one A Break at the end of each Case tells the computer to skip the rest of the conditions Use End Case to end the statement The results will be the same as a correctly coded multiple-alternative If-Then-Else structure
Example Select Case of Choice Case 1: Set Operation = “Add” Break Set Operation = “Subtract” Case 3: Set Operation = “Multiply” Case 4: Set Operation = “Divide” End Case
Any Questions ?