Skip to main content
A-LevelComputer ScienceProgramming9618/23 · Oct/Nov 2022 · Q517 Marks

A text string contains three data items concatenated as shown: <StockID><Description><Cost> Item lengths are: Item Length StockID 5 Description 32 Cost the remainder of the string A procedure Unpack() takes four parameters of type string. One parameter is the original text string. The other three parameters are used to represent the three data items shown in the table and are assigned values within the procedure. These values will be used by the calling program after the procedure ends. Write pseudocode for the procedure Unpack().

  1. (a)(i)A text string contains three data items concatenated as shown: <StockID><Description><Cost> Item lengths are: Item Length StockID 5 Description 32 Cost the remainder of the string A procedure Unpack() takes four parameters of type string. One parameter is the original text string. The other three parameters are used to represent the three data items shown in the table and are assigned values within the procedure. These values will be used by the calling program after the procedure ends. Write pseudocode for the procedure Unpack().[6]
  2. (a)(ii)Explain the term procedure interface with reference to procedure Unpack().[2]
  3. (b)(i)The design changes and a record structure is defined to store the three data items. A user-defined data type StockItem is created as shown: TYPE StockItem DECLARE StockID : STRING DECLARE Description : STRING DECLARE Cost : REAL ENDTYPE A variable LineData of type StockItem is declared. Write the pseudocode statement to assign the value 12.99 to the Cost field of LineData.[1]
  4. (b)(ii)Procedure Unpack() is modified and converted to a function which takes the original text string as the only parameter. Explain the other changes that need to be made to convert the procedure into a function.[2]
  5. (c)Unpack() is part of a program made up of several modules. During the design stage, it is important to follow good programming practice. One example of good practice is the use of meaningful identifier names. Give the reason why this is good practice. Give two other examples of good practice. Reason Example 1 Example 2[3]
  6. (d)The program that includes Unpack() is tested using the walkthrough method. Describe this method and explain how it can be used to identify an error.[3]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.

  1. [6] One mark per point: 1 Procedure heading and ending including four parameters... 2 ...and use of BYREF for the three extracted values 3 Extract and assign SID 4 Extract and assign SDesc 5 Calculation of length of SCost (remainder of string) 6 Extract and assign SCost following an attempt at MP5 PROCEDURE UnPack(BYVAL TLine : STRING, BYREF SID, SDesc, SCost : STRING) SID ← LEFT(TLine, 5) SDesc ← MID(TLine, 6, 32) SCost ← RIGHT(TLine, LENGTH(TLine) – 37) ENDPROCEDURE
  2. [2] One mark each (Max 2): 1 Provides a mechanism to allow calling program to pass data 2 Defines the four parameters of Unpack() 3 ... giving their data type and order
  3. [1] LineData.Cost ← 12.99
  4. [2] One mark per point (Max 2): • The new function will return an item of type StockItem • Need to declare/use a (local) variable of type StockItem • Costfield needs to be converted from a string to a real
  5. [3] One mark for reason One mark for each example (Max 2) Reason: • Makes the code easier to understand // Describes the purpose of the identifier // Makes the code easier to debug/test/maintain Further examples include: • White space • Indentation • Keywords in capitals • Comments • Local variables // parameters
  6. [3] One mark per point (Max 3): 1 The program is checked by creating a trace table / going through the program a line at a time 2 ....to record/check variable (values) as they change 3 Error may be indicated when variable given an unexpected value 4 Error may be indicated by an unexpected path through the program // Faults in the logic of the program can be detected

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Programming, A-Level Computer Science (syllabus 9618). Structured question, 17 marks.
Source
A-Level Computer Science, Oct/Nov 2022 Paper 2 Variant 3, question 5.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep