Question 6(b) 2021 · May-June · Paper 23 · 16 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (b)
Question 6
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Show text version of question
Question 6
Part (b)
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 (b)
Write program code for a module GroupReport(), which will summarise the stock data for
a given product group.
The product group will be passed to the module as a string. The total value of items is calculated by multiplying the cost by the quantity.
An example of the output for group ABLK is as follows:
Group: ABLK Number of items in Group: 11 Total value of items in Group: 387.89
If no items are found for group ABLK, the output is as follows:
There are no items in Group: ABLK
Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.
Programming language ............................................................................................................
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Question 19
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 20
Why this question appears here
83% assigned-topic match · Programming › Structured programming
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
