10. Flowcharts What to Wear

ELSEIF (or ELSE IF) is used in pseudocode to handle multiple conditions in a decision-making structure.
It allows you to check additional conditions if the first IF condition is false — without ending the decision block.
The pseudocode below shows an algorithm, with 2 decision steps, that suggests what to wear based on the temperature input by the user.
ALGORITHM whatToWear()

BEGIN
    INPUT temperature
    IF temperature < 10 THEN
        PRINT "Wear a coat."
    ELSEIF temperature < 20 THEN
        PRINT "Wear a jumper."
    ELSE
        PRINT "Wear a shirt."
    ENDIF
END
../_images/what_to_wear.png


Tasks

  1. In the pseudocode above, there are two lines that end with THEN. What keywords do those lines start with?

  2. What do you wear if the first condition is False and the second is True?

  3. What do you wear if all conditions are False?

In the pseudocode above, there are two lines that end with THEN. What keywords do those lines start with?

IF and ELSEIF

What do you wear if the first condition is False and the second is True?

A jumper.

What do you wear if all conditions are False?

A shirt.