If the condition is true, the code will branch one way. If the condition is false, the code will branch another way. When the condition is true, the code contained in the first section of the block is processed sequentially. The code in the second section of the block is skipped. When the condition is false, the first section is skipped, and the second section is processed. Consider the code created in Hands-On Example 5-3A. If the user enters an age greater than or equal to 18, the condition is true. In this case, the code provides the user with a statement. If the user enters an age less than 18, the condition is false. However, the code does not provide any sort of output to the user. You might have felt that the user deserved some explanation. The IF…THEN…ELSE statement provides this alternative path for the code. The project created in Hands-On Example 5.3A did not provide an alternate path for the code if the condition is false. As a result, the program did not let the user know he or she is too young to vote. By using the IF…THEN…ELSE block, the program can be improved to provide this information. Hands-On Example 5.3B Hands-On Example 5.3B Branching Code C 1 Launch Scratch, , and open the HOE05-03A projec ct . Save it as HOE05-03B in your working folder. 2 Disconnect the existing code as shown. Do this b by dragging the blocks apart. Click the block to detach, , hold, and drag to disconnect the e block. when clicked ask What is your age? and wait or answer 18 answer = 18 if then say You are old enough to vote. Goodheart-Willcox Publisher 3 Drag the if then block b into the Blocks palette to d de lete it from the code. 4 Drag the if then e el se block from the Blocks palett te and drop it onto the bottom of the code stack. 5 Drag the existin ng condition into the if then else bl lo ck. 6 Drag the existin ng say block into the first section o of the if then else block. This will be processed if the condition is true. Continued Copyright Goodheart-Willcox Co., Inc. 110 Introduction to Computer Science: Coding