Continued 7 Applying what you y have learned, add a say block k to the second section of the if then else block, as shown n. Change the text to “You are not old enough to vote.” when clicked ask What is your age? and wait else if then or answer 18 answer = 18 say You are old enough to vote. say You are not old enough to vote. Goodheart-Willcox Publisher 8 Click the Green Flag button to run the program. Run the program several times to test it, entering differen nt values each time. Notice that if f the user enters 17 or less, the program provides the alte er native message. 9 Save the project t. Try It! Consider an adventure e game. During gameplay, the player p is presented with two doors, and he or she must choose to op pe n one. This is a branch in gameplay y. Opening door 1 allows the player to enter the castle. Opening door o 2 reveals a tiger and the game is over. o Create a project that asks the player which door to choose and states a the outcome to the player. Save t th e project as TI05-03B in your working folder. Green Flag Creating Nested Decisions Nesting is a technique in which one decision g is contained within another decision. Nesting is used whenever a second decision depends on the outcome of a first decision. It is also used to make code more efficient. The concept of nesting can be thought of as the Russian matryoshka nesting dolls, as shown in Figure 5-7. Each doll sits inside another doll. For example, consider calculating a letter grade based on a numerical score. Suppose a percentage grade average is stored in the variable named percent. The following statements convert that percentage to a letter grade. IF percent 90 OR percent = 90 THEN letter = A IF percent 80 OR percent = 80 THEN letter = B IF percent 70 OR percent = 70 THEN letter = C IF percent 60 OR percent = 60 THEN letter = D IF percent 60 THEN letter = F Nor Gal/Shutterstock.com Figure 5-7. Matryoshka nesting dolls fit inside one another, just like nested decisions in computer code. Copyright Goodheart-Willcox Co., Inc. Chapter 5 Decisions 111