Curriculum

Curriculum

Write Pseudocode for Multi-Branch Decisions

Scenario

Turn the classroom badge flowchart (Distinction >= 85, Pass >= 60, Try again < 60) into pseudocode.

  1. 1…
  2. 2…
  3. 3…
Pseudocode
FUNCTION classify_badge(score):
  IF score >= 85 THEN RETURN "Distinction"
  ELSE IF score >= 60 THEN RETURN "Pass"
  ELSE RETURN "Try again"

Try it yourself

Order the pseudocode lines from highest threshold down to the fallback ELSE.

Reveal the explanation
  1. IF score >= 85 THEN RETURN "Distinction"

    Handles the highest tier first so it is never shadowed.

  2. ELSE IF score >= 60 THEN RETURN "Pass"

    Runs only for scores from 60 to 84.

  3. ELSE RETURN "Try again"

    Guarantees every remaining score below 60 returns an explicit value.

Using ELSE IF (instead of independent IF blocks) ensures exactly one branch runs and maps cleanly to Python elif, JS else if, and Go else if.

Review first

Your turn

Write 3-branch pseudocode for room status: freeSeats == 0 -> "Full", freeSeats == 1 -> "Last seat", else -> "Open".

Common mistake Writing separate IF statements without ELSE IF so multiple branches execute or overwrite each other.

Check your work

IF freeSeats == 0 -> "Full"; ELSE IF freeSeats == 1 -> "Last seat"; ELSE -> "Open".

Quick check

Why should a final ELSE appear at the end of a multi-branch pseudocode chain?
Show the answer and reasoning

Correct answer It guarantees every valid input produces an explicit outcome

A closing ELSE ensures no valid input falls off the end without returning a result.