#P3001. CAIE IGCSE CS Speciman Paper B 2023 Paper 2 Problem 13

CAIE IGCSE CS Speciman Paper B 2023 Paper 2 Problem 13

The names of patients are stored in the one-dimensional (1D) array PatientPatient of type string.
A separate two-dimensional (2D) array ReadingsReadings stores the latest data recorded about each patient. The array contains the readings taken by a nurse for each patient:

  • temperature measured to one decimal place
  • pulse rate, a whole number. Temperature readings should be in the range 31.631.6 to 37.237.2 inclusive.
    Pulse readings should be in the range 55.055.0 to 100.0100.0 inclusive.
    The hospital number given to the patient is used for the index on both arrays, this is a value between 11 and 10001000 inclusive.
    When the data for a patient is checked a warning is given if any of the readings are out of range.
    If both readings are out of range, then a severe warning is given.

Write a procedure, using pseudocode or program code, that meets the following requirements:

  • takes the hospital number as a parameter
  • checks if the number is valid
  • outputs an error message and exits the procedure if the number is not valid
  • if the hospital number is valid: – output the patient’s name – output ‘Normal readings’ if both the readings are within range – output ‘Warning’ and the name of the reading e.g. ‘Pulse’ if one reading is out of range – output ‘Severe warning’ and the names of the two readings ‘Pulse and temperature’ if both readings are out of range – exits the procedure.

INPUT FORMAT

The first line contains PatientSize(PatientSize<=1000)PatientSize (PatientSize <= 1000), the ClassSize, and QueryTimes(QueryTimes<=100)QueryTimes (QueryTimes <= 100), representing QueryTimesQueryTimes queries
The second line contains PatientSizePatientSize patients' names
The third line contains PatientSizePatientSize patients' Temperature
The fourth line contains PatientSizePatientSize patients' Pulse Rate
After that, there are QueryTimesQueryTimes lines, each line contains one HospitalNumber(HospitalNumber<=1000)HospitalNumber (HospitalNumber <= 1000)

OUTPUT FORMAT

For each queries, if the hospital number is valid

  • Output the patient’s name
  • Output Normal readings if both the readings are within range
  • Output Warning and the name of the reading, and Pulse Rate or Temperature
  • Output Severe warning and the names of the two readings Pulse Rate and Temperature if both readings are out of range

Otherwise, Output Invalid and exits the procedure if the number is not valid

You should declare all variables you used

SAMPLE

INPUT

5 7
Alice Bob Carol Dave Eve
36.5 38.0 36.8 30.0 31.6
72 80 104 110 55
1
2
3
4
5
0
6

OUTPUT

Alice
Normal readings
Bob
Warning Temperature
Carol
Warning Pulse Rate
Dave
Severe warning Pulse Rate and Temperature
Eve
Normal readings
Invalid
Invalid