
If (<Boolean expression>) Then 
Remember that a Boolean variable is one that is either true or false. Similarly, a Boolean expression is one that is either true or false. We can fill in our selection form using the lightbulb example:
If (switch is on) Then 
Whenever we have more than two options, we can add branches to our selection statement using the keywords Else If. The box below shows an example form for three alternatives:
If (<Boolean expression>) Then 
The Selection Tutorial will give you some practice at writing selection statements on your own. Click on the link below to start the Selection Tutorial in a new window. Once you finish the tutorial, continue reading the remainder of this lesson.
Now let's consider how we can make our simple tax program more sophisticated using the selection control structure. Suppose that we added two variables to our program: state and taxRate. The state variable represents one of two states: Virginia or Tennessee. The taxRate variable represents a state's sales tax rate. In this case, the tax rate is either 4.5% for Virginia or 6.0% for Tennessee. This variable taxRate replaces our previous constant TAXRATE. Using these variables and our selection control structure, we can have our program chose the appropriate tax rate and calculate the correct sales tax for either state.
Modified Tax Program 
Integer
VIRGINIA := 1 
Our variable state is testing to see what is the current state, and then the appropriate sales tax is selected. Of course, we could extend our program to include the tax rates from other states by adding more constants and Else If branches to the program. For example, to add the state of Maine, we would make the following changes:
Integer
VIRGINIA := 1 