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 number | moisture | isHot | volume | Output |
|---|---|---|---|---|
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.