AGE contains 77. Which branch of the IF of this little program will execute?
The false branch will execute.
This false branch contains just a single statement
LET RATE = 0.75
which will execute without any further bother.
After it executes the complete IF
structure
everything between the first IF
and its matching END IF
is finished.
Here is a review of what happened.
The statements are numbered in the order that
they executed:
(1) PRINT "Enter full fare" (2) INPUT FARE <-- $400 (3) PRINT "Enter age" (4) INPUT AGE <-- 77 ' 'Calculate discount based on age (5) IF AGE < 12 THEN <-- false LET RATE = 0.0 ELSE (6) IF AGE < 24 THEN <-- false LET RATE = 0.70 ELSE (7) IF AGE < 65 THEN <-- false LET RATE = 1.0 ELSE (8) LET RATE = 0.75 END IF END IF END IF 'Calculate fare (9) PRINT "Your fare is:", FARE * RATE <-- 400 * 0.75 (10)END
Do you find this program a little bit confusing?