Programming fundamentals
84
0/1

A laboratory inventory system tracks hazardous chemical containers. Each container material has a specific code, as shown below:

CodeMaterial
GLGlass
PLPlastic
MTMetal

A program is written to log new batches into the inventory database. The program:

  • prompts the operator to input the container material code
  • prompts the operator to input the unique batch number
  • calls the prewritten function IsValidContainer() to check whether the entered material code is valid
  • if valid, combines the material code and batch number with a hyphen, and calls the procedure RegisterBatch() to update the database
01  containerCode = input("Enter container material code: ")
02  batchNum = input("Enter batch number: ")
03  if (IsValidContainer(containerCode)) then
04      trackingRef = containerCode + "-" + batchNum
05      RegisterBatch(trackingRef)
06  else
07      print("Error: Invalid container code.")
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