Question 6(b) 2021 · May-June · Paper 21 · 16 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (b)
Question 8
Show text version of question
Question 6
Part (b)
Question 6
A program stores stock data in four global arrays as follows:
Example Initial data Array Data type Description data value value The stock item ID StockID STRING "HWDM0001" "" (Eight alpha-numeric characters)
Description STRING "Candle" "" (Alphabetic characters only) Quantity INTEGER The number in stock 4 0 Cost REAL The cost of the item 2.75 0
- Each array contains 10 000 elements.
- Elements with the same index relate to the same stock item. For example, StockID[4]
- The StockID array is not sorted and unused elements may occur at any index position.
- Unused elements are assigned the initial data value shown in the table above.
contains the ID for the product whose description is in Description[4].
The program is to be modified so that the data from the arrays can be stored in a text file for backup.
The programmer has started to define program modules as follows:
Module Description GetValidFilename() • prompts, inputs and returns a valid filename
- called with an array index as a parameter
Check()
- checks that the data values for the stock item with the given
- returns TRUE if the values are valid, otherwise returns FALSE
- calls GetValidFilename() to get the name of the backup file
- combines the data values for each stock item to form a single
- writes the string to the backup file
- calls Check() to validate the data values. If there is an error
- repeats for all stock items
- returns TRUE if nothing was written to "ERRORLOG.TXT",
- called with two parameters:
- extracts the four data values from the string and assigns each
index are valid
string. Inserts an asterisk character '*' as a separator between data values
Backup()
then also writes the string to the file "ERRORLOG.TXT"
otherwise returns FALSE
o an array index Unpack() o a string value read from one line of the backup file
to the appropriate array
Question 17
Part (b)
Write pseudocode for the module Backup().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Question 19
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 20
Why this question appears here
83% assigned-topic match · Data types and structures › Data types and records
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_s21_qp_21.pdf
