Question 6(a) 2021 · May-June · Paper 23 · 18 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (a)
Question 8
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Question 7
Question 8
Show text version of question
Question 6
Part (a)
Question 6
A program stores data about stock items in four global 1D arrays as follows:
Example Initial data Array Data type Description data value value the stock item ID StockID STRING (eight alpha-numeric "ABLK0001" "" characters) a description of the item Description STRING "torch" "" (alphabetic characters only) Quantity INTEGER the number in stock 6 0
Cost REAL the cost of the item 4.80 0.0
- Each array contains 10 000 elements.
- Elements with the same index relate to the same stock item. For example, StockID[5]
contains the ID for the product whose description is in Description[5].
- 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.
- The first four characters of the StockID represent a product group. The last four characters
represent the item within the group.
The program is to be modified so that:
- data from the arrays are stored in a text file for backup purposes. Data from unused elements
are not stored in the file.
- a Summary array is added. This will be a global 1D array of 500 elements of type STRING.
Each product group will occur once in the array, for example "ABLK" for the item in the table above.
The programmer has started to define program modules as follows:
Module Description
- prompts and inputs a filename
- returns a valid filename as a STRING
- calls GetValidFilename() for a filename
- checks if the file is empty
- returns the filename.
GetValidFilename()
CheckBackupFile() • If the file is not empty ask the user to confirm that overwrite is intended. If not intended allow the user to re-input a different filename.
Question 17
Part (a)
Write pseudocode for the module CheckBackupFile().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 18
Why this question appears here
83% assigned-topic match · Programming › Constructs
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_23.pdf
