OCR GCSE Computer Science June 2022 Paper 2, Question 2(a): the half-price meal logic circuit

OCR J277/02 June 2022, Question 2(a): complete the logic diagram for P = (A OR B) AND NOT C, describe the purpose of a truth table and say how many rows it needs. Worked through, with a program that prints the truth table.

Past paper questionOCR J277/02June 2022 Paper 26 marksLogic

Question 2(a) of the OCR GCSE Computer Science Paper 2 sat on 27 May 2022 (J277/02, Computational thinking, algorithms and programming) is about a logic system for a restaurant offer. You draw three gates (3 marks), describe what a truth table is for (2 marks) and say how many rows this one needs (1 mark).

We do not copy the exam paper here. Open it beside this page: OCR June 2022 J277/02 question paper (PDF). When you have finished, check the mark scheme too.

The question in short

A customer gets a half-price meal if they are a student or have a discount card, but not on a Saturday. The inputs are A (is a student), B (has a discount card) and C (it is Saturday). The logic is:

P = (A OR B) AND NOT C

The diagram on the paper has three empty boxes, one for each gate.

Part (i): the three gates

  • The box fed by A and B is an OR gate: curved back, pointed front.
  • The box fed by C alone is a NOT gate: a triangle with a small circle on its point.
  • The box that joins them and leads to P is an AND gate: flat back, round front, like a letter D.

One mark for each gate. The mark is for the shape, not for a name written in the box.

Part (ii): what is a truth table for?

It shows every possible combination of inputs, and the output that each combination gives.

Both halves are needed for 2 marks. "All the combinations of inputs and outputs" only earns the first, because it does not say that each output belongs to a set of inputs.

Part (iii): how many rows?

8. Each input can be 0 or 1, and there are three of them: 2 x 2 x 2.

Where the marks are lost

  • No circle on the NOT gate. Without the circle it is not a NOT. The OR and AND gates must not have one.
  • Writing "OR" in a box and drawing nothing. The mark scheme marks the shape.
  • AND where OR should be. Match the gates to the brackets: (A OR B) is worked out first, so A and B meet at the OR gate.
  • 6 rows, or 3. Rows double with each input: 2, 4, 8, 16.

Run it

This prints the truth table for the offer. Read the rows as customers. Set one customer at the top, and the robot's light shows whether they get the offer.

Eight rows. P is 1 for three of them: the rows where it is not Saturday and the customer is a student, has a card, or both.
The program
from bugbot import *
connect()

# one customer to check: change these
STUDENT = 1
CARD = 0
SATURDAY = 0

print("A B C  P")
for A in [0, 1]:
    for B in [0, 1]:
        for C in [0, 1]:
            P = (A or B) and not C
            print(A, B, C, "", int(P))

if (STUDENT or CARD) and not SATURDAY:
    led("green")
    print("Half price")
else:
    led("red")
    print("Full price")
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is the answer to OCR J277 June 2022 Paper 2 Question 2(a)(i)?

An OR gate with inputs A and B, a NOT gate with input C, and an AND gate that takes the outputs of those two gates and produces P.

What is the purpose of a truth table?

To show all the possible combinations of inputs to a logic circuit, together with the output produced by each combination.

How many rows does a truth table need?

2 to the power of the number of inputs: 2 rows for one input, 4 for two, 8 for three and 16 for four.

More from this paper

Every OCR J277 question we have worked · Guide: Logic gates and truth tables explained

Learn it step by step

  1. F9.1 Logic gates and truth tables Logic and computer systems
  2. F9.2 Logic circuits and expressions Logic and computer systems
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.