LearnStanmorephysics

Grade 10 · Delphi Foundations

AND, OR and IF ladders

Grade 10 · Decisions · Lesson and coding task · about 14 minutes

Open this task in the Delphi workspace →

Conditions combine with AND, OR and NOT. In Delphi each comparison must be in its own brackets:

if (rAvg >= 75) and (iMaths >= 70) then   // both must be true
if (sDay = 'Sat') or (sDay = 'Sun') then   // at least one true

Leave the brackets out and Delphi refuses to compile — a classic exam-day panic that you are now vaccinated against.

For several possibilities in a row, chain IFs into a ladder. Order matters: test the strictest condition first.

if (rAvg >= 75) and (iMaths >= 70) then
  lblResult.Caption := 'Bursary awarded!'
else
  if rAvg >= 75 then
    lblResult.Caption := 'So close - improve your Maths mark'
  else
    lblResult.Caption := 'Keep working at it';

Your task: bursary checker

A university bursary requires an average of at least 75% AND a Maths mark of at least 70%. Implement exactly the ladder above.

What you will do

Hints
  1. Each comparison gets its own brackets: (rAvg >= 75) and (iMaths >= 70)
  2. The second rung of the ladder only needs to test the average — the Maths mark already failed if we got there.
  3. No semicolons before the elses!
Model solution
procedure TfrmBursary.btnApplyClick(Sender: TObject);
var
  rAvg : Real;
  iMaths : Integer;
begin
  rAvg := StrToFloat(edtAvg.Text);
  iMaths := StrToInt(edtMaths.Text);
  if (rAvg >= 75) and (iMaths >= 70) then
    lblResult.Caption := 'Bursary awarded!'
  else
    if rAvg >= 75 then
      lblResult.Caption := 'So close - improve your Maths mark'
    else
      lblResult.Caption := 'Keep working at it';
end;

About this material

This platform provides original CAPS-aligned practice material and study tools. Content is machine-verified and has not been reviewed by subject specialists. It is not affiliated with or endorsed by the Department of Basic Education. Learners should also use official past papers and consult their teachers where uncertain.