OCR GCSE Computer Science (J277) · Algorithms and programming (Paper 2) › Algorithms › Designing, creating and refining algorithms
Practise Inputs, processes, outputs and structure diagrams. 12 exam-style questions on this subtopic, at up to four difficulty levels, with full mark schemes and a progress tracker. Free, no account needed.
Written for this site in the style of OCR exam questions. They are not taken from real past papers.
Question 1Easy3 marks
(a) A program for a school canteen records the items a pupil chooses and prints a receipt. Which one of these is a process? Tick (✓) one box.[1]
The pupil scanning their ID card
Adding up the prices of the items chosen
Printing the receipt
Displaying the menu on a screen
(b) State what a structure diagram shows.[1]
(c) Give one advantage of drawing a structure diagram before writing a program.[1]
Show the answer and mark scheme
(a)Answer: Adding up the prices of the items chosen
(b)
how a problem / program is broken down into smaller sub-problems / modules (and how they are related)
(c)
shows the modules / sub-programs that need to be written
helps to decompose the problem so each part is easier to solve
parts can be given to different programmers
gives an overview of the whole solution / shows how the parts fit together
Question 2Medium6 marks
A car park charges £2.50 for each hour or part of an hour, up to a maximum charge of £15.00. A program is given the number of minutes a car has been parked and outputs the charge.
(a) State the input to this program.[1]
(b) Describe the processing that the program must carry out.[3]
(c) State the output of the program when a car has been parked for 130 minutes.[1]
(d) Explain why the program does not need to know the registration number of the car.[1]
Show the answer and mark scheme
(a)
the number of minutes (the car has been parked)
(b)
convert the minutes to hours, rounding any part of an hour up (e.g. hours = (minutes + 59) DIV 60)
multiply the number of hours by 2.50
if the charge is more than 15.00, set it to 15.00
(c)Answer: £7.50 (3 hours or part hours) £
£7.50
(d)
the charge only depends on the time parked / the registration number is not used in the calculation
Question 3Hard10 marks
A smart greenhouse is controlled by a computer program. Sensors measure the temperature, the moisture of the soil and the light level. The program can open or close a window, switch a heater on or off and switch a water sprinkler on or off.
(a) Identify two inputs and two outputs of the program.[4]
(b) The program must keep the temperature between 18 °C and 26 °C. Describe the processing needed to control the temperature.[3]
(c) Draw a structure diagram for the greenhouse program. Your diagram should have at least two levels below the top box.[3]
Show the answer and mark scheme
(a)
input: one sensor reading, e.g. the temperature / soil moisture / light level
input: a second, different sensor reading
output: one control signal, e.g. to open / close the window
output: a second, different control signal, e.g. to switch the heater / sprinkler on or off
(b)
read the temperature repeatedly / in a loop
if the temperature is below 18, switch the heater on (and close the window)
if the temperature is above 26, switch the heater off / open the window
otherwise (18 to 26) switch the heater off and close the window / leave them unchanged
wait a set time before checking again
(c)
a top box for the whole system, e.g. "Greenhouse controller"
at least three sensible modules at the next level, e.g. control temperature, control watering, read sensors
at least one module broken down further, e.g. "control temperature" into "read temperature", "control heater", "control window"