Skip to content
Programming Decision making
All classes Intermediate About 15 min Premium

Did the student pass?

Enter marks in maths, science and English and run a result program: it works out the total and the percentage, checks with AND that every subject is passed, and then uses nested if / else to give the division. Find the marks that reach each branch.

Core concept

Conditions can be joined with AND (all must be true) and OR (one is enough), and an if / else can sit inside another, so the program checks one question after another until one is true

Topic: Decision making

A school result is a chain of decisions. First: did the student pass every subject? A student who scores 95 in two subjects but 25 in the third has still failed. That check joins three condition: A question with a yes or no answer that decides what the program does next. All key words with AND: maths >= 35 AND science >= 35 AND english >= 35 is true only if all three are true. (With OR, one true part would be enough.) Only then does the program look at the percentage, from the top: 80 or more is a distinction; if not, 60 or more is a first division; if not, 45 or more is a second division; otherwise just a pass. Each ELSE IF is asked only when every question above it was false.

Key words explained

What you will learn

  • Work out a total and a percentage in a program.
  • Explain when a condition joined with AND or OR is true.
  • Trace nested if / else and say which branch runs.
  • Find inputs that reach a given branch, and complete a missing condition.

Before you start

  • Know if / else and the signs >, >= and <.

Materials

  • Your own (or made-up) marks for three subjects

Equipment

  • None

Procedure

  1. Run the program with the starting marks and see the division.
  2. Make one subject fail and run it again.
  3. Find marks that give a distinction.
  4. Answer the practice challenges.
Premium experiment Create a free account