Designing, creating and refining algorithms
11
0/4

An automated garden irrigation system uses the following algorithm to calculate the volume of water, in litres, to deliver to a flowerbed:

01  moisture = input("Enter soil moisture %")
02  isHot = input("Is it a hot day? (Y/N)")
03  if moisture < 20.0 then
04      volume = 15
05  elseif moisture < 50.0 then
06      volume = 10
07  else
08      volume = 4
09  endif
10  if isHot == "Y" then
11      volume = volume + 5
12  endif
13  print("Water volume:", volume, "litres")

Complete the trace table for the algorithm when the soil moisture is input as 38.5 and the hot day status is input as "Y".

You may not need to use all the rows in the table.

Line numbermoistureisHotvolumeOutput
[4]

Designing, creating and refining algorithms Questions

Practise OCR GCSE Computer Science Designing, creating and refining algorithms with exam-style questions for GCSE Computer Science. 50 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Designing, creating and refining algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Designing, creating and refining algorithms