Programming fundamentals
6
0/1

An automated greenhouse irrigation system controls watering zones. Each zone has a specific code, as shown in the table below:

CodeZone Type
NTNorth Tunnel
STSouth Tunnel
HPHydroponics

A program is written to update irrigation settings. The program:

  • displays an initialising message
  • asks the user to enter the zone code
  • calls the prewritten function CheckZoneValid() to check whether the entered code is valid
  • if valid, asks the user to input the target soil moisture percentage, combines them to form a control command, and calls a procedure QueueCommand()
01  print("Irrigation System Controller v2.1")
02  zoneCode = input("Enter zone code: ")
03  isValid = CheckZoneValid(zoneCode)
04  if (isValid == true) then
05      targetMoisture = input("Enter target soil moisture percentage: ")
06      controlCommand = zoneCode + ":" + targetMoisture
07      QueueCommand(controlCommand)
08  endif

Give the line number that contains the call to the prewritten validation function.

[1]

Programming fundamentals Questions

Practise OCR GCSE Computer Science Programming fundamentals with exam-style questions for GCSE Computer Science. 100 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

Programming fundamentals Questions

  1. GCSE
  2. /Computer Science
  3. /Programming fundamentals