Question 1 Report
Table 1 shows data exported from a wildlife rescue centre. Volunteers use a program to record animals that arrive during one day. Each row will become a record in an array called admissions. The program uses the data to display a daily total by species and to find animals ready for release.
| Array position | Admission code | Species | Mass / g | Ready for release | Days in care |
|---|---|---|---|---|---|
| 0 | R-2401 | Hedgehog | 680 | false | 3 |
| 1 | R-2402 | Swift | 41.5 | true | 12 |
| 2 | R-2403 | Hedgehog | 725 | true | 9 |
| 3 | R-2404 | Bat | 9.8 | false | 1 |
| 4 | R-2405 | Swift | 39.0 | true | 7 |
The code editor has the following field names: code, species, mass, ready and days. The program must only use correct array positions. At the end of the day, the data file is encrypted for transfer to a regional database.
(a) Identify the array position of the bat record. [1]
(b) Write the most suitable data type for each of code, mass, ready and days. [4]
(c) Give two reasons why an array of records is more suitable than five separate arrays for this program. [3]
(d) Complete the pseudocode that counts animals ready for release.releaseTotal = 0FOR i = 0 TO 4 IF admissions[i].ready = _____ THEN releaseTotal = releaseTotal + _____ ENDIFNEXT i [3]
(e) Use Table 1 to state the value displayed in releaseTotal. [2]
(f) Complete a condition that identifies a hedgehog ready for release.IF admissions[i].species = "Hedgehog" _____ admissions[i].ready = true THEN [2]
(g) State two test data values for days, one valid boundary value and one invalid value, assuming the permitted range is 0 to 365. [4]
(a) The bat record is at array position 3. [1]
(b) Suitable field types are: code, String [1]; mass, Real or floating-point [1]; ready, Boolean [1]; and days, Integer [1]. [4]
(c) An array of records keeps all fields for one animal together [1], so one array element represents one admission [1]. It reduces the chance that matching positions in separate arrays become unsynchronised [1]. It also makes searching, adding, and saving a complete admission easier. [3]
(d) The loop checks each of the five records [1]. A ready animal adds one to the counter:
releaseTotal = 0
FOR i = 0 TO 4
IF admissions[i].ready = true THEN
releaseTotal = releaseTotal + 1
ENDIF
NEXT itrue gains [1] and adding 1 gains [1]. [3]
(e) Three records are ready for release: the swift at position 1, hedgehog at position 2, and swift at position 4. Therefore releaseTotal is 3. [2]
(f) Both facts must be true, so use:
IF admissions[i].species = "Hedgehog" AND admissions[i].ready = true THEN
[2]
(g) A valid boundary test value is 0 or 365 [1], identified as valid boundary data [1]. An invalid value could be -1 or 366 [1], identified as outside the permitted range [1]. [4]
Everything you need to excel in your exams