OCR GCSE Computer Science June 2022 Paper 2, Question 2(b): the half-price meal flowchart

OCR J277/02 June 2022, Question 2(b): design a flowchart that inputs three values, decides whether a customer gets a half-price meal, and outputs the result. The shapes, the order of the decisions, the five marks explained, and the algorithm to run.

Past paper questionOCR J277/02June 2022 Paper 25 marksWrite a program

Question 2(b) of the OCR GCSE Computer Science Paper 2 sat on 27 May 2022 (J277/02) asks you to design an algorithm as a flowchart. It is worth 5 marks. Pseudocode or Python gets nothing here, however correct: the question names the form.

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. The offer is not valid on Saturdays. The algorithm should input the data it needs, decide, and output the result.

Plan it

Three things decide the outcome, so there are three inputs: is it Saturday, is the customer a student, do they have a discount card.

Ask about Saturday first. If it is Saturday nothing else matters, and the flowchart is simpler.

The flowchart

  1. Start (rounded box).
  2. INPUT saturday, student, card (parallelogram). Three separate parallelograms are fine too.
  3. Decision (diamond): saturday == "yes"? The Yes exit goes to the output "Full price".
  4. The No exit goes to a second diamond: student == "yes"? Its Yes exit goes to the output "Half price".
  5. Its No exit goes to a third diamond: card == "yes"? Yes goes to "Half price". No goes to "Full price".
  6. Both outputs (parallelograms) lead to End.

You can also do it with one diamond holding the whole condition: not Saturday AND (student OR card).

Where the five marks are

  • a start and an end, with every box connected and no dead ends;
  • three inputs, in parallelograms;
  • all three things checked, in diamonds, with two lines out of each;
  • "Full price" output under the right conditions, in a parallelogram;
  • "Half price" output under the right conditions, in a parallelogram.

The last two are only given if the decisions are right for every customer. Check yours against the eight combinations: half price is only the three where it is not Saturday and the customer is a student, has a card, or both.

Where the marks are lost

  • Not drawing a flowchart. See above.
  • One exit from a diamond. Every decision needs two labelled lines.
  • Forgetting Saturday. A student on a Saturday pays full price.
  • No inputs. The data has to come from somewhere. Show it being input.
  • Rectangles for input and output. The wrong shape is penalised once.

Run it

The same decisions in Python, in the same order as the flowchart. Type yes or no.

Try no, yes, no for half price. Try yes, yes, yes for full price: Saturday beats everything.
The program
from bugbot import *
connect()

saturday = input("Is it Saturday? ")
student = input("Is the customer a student? ")
card = input("Do they have a discount card? ")

if saturday == "yes":
    result = "Full price"
elif student == "yes":
    result = "Half price"
elif card == "yes":
    result = "Half price"
else:
    result = "Full price"

print(result)
if result == "Half price":
    led("green")
else:
    led("red")
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(b)?

A flowchart that inputs whether it is Saturday, whether the customer is a student and whether they have a discount card, then uses decisions to output half price when it is not Saturday and the customer is a student or has a card, and full price otherwise.

Can I answer a flowchart question in pseudocode?

No. If the question says to design the algorithm using a flowchart, another form does not answer the question and is not marked.

How many exits does a decision box have?

Two, labelled Yes and No or True and False. Each must lead somewhere.

More from this paper

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

Learn it step by step

  1. F5.2 Flowcharts Algorithms
  2. F2.3 else, elif and Boolean operators Decisions and loops
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.