Write Pseudocode for Multi-Branch Decisions
Scenario
Turn the classroom badge flowchart (Distinction >= 85, Pass >= 60, Try again < 60) into pseudocode.
- 1…
- 2…
- 3…
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
- IF score >= 85 THEN RETURN "Distinction"
Handles the highest tier first so it is never shadowed.
- ELSE IF score >= 60 THEN RETURN "Pass"
Runs only for scores from 60 to 84.
- 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.
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
This browser could not save your progress. Changes last until you leave the page.