4. A company employs Ahmed as a programmer.
(a) At College, before joining the company, Ahmed used two items of software for programming:
• a text editor
• a compiler
Describe how he could have developed programs using these software tools. Include in the description the terms ‘object code’ and ‘source code’.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
(b) Ahmed now uses an Integrated Development Environment (IDE) for programming.
(i) State one feature an IDE provides to help with the identification of syntax errors.
...........................................................................................................................................
.......................................................................................................................................[1]
(ii) State one feature an IDE provides to carry out white box testing.
...........................................................................................................................................
.......................................................................................................................................[1]
(c) The company maintains a file of product data. Ahmed is to write a program to add a new product and search for a product based on the structure diagram shown:

The program records the following data for each product:
• product code
• product description
• product retail price
The text file PRODUCTS stores each data item on a separate line, as shown below:

The program uses the variables shown in the identifier table.
Identifier
Data type
Description
PRODUCTS
TEXT FILE
Storing the code, description and retail price for all current products
PCode
ARRAY[1:1000] OF STRING
Array storing the product codes
PDescription
ARRAY[1:1000] OF STRING
Array storing the product descriptions
PRetailPrice
ARRAY[1:1000] OF REAL
Array storing the product retail prices
i
INTEGER
Array index used by all three arrays
(i) The first operation of the program is to read all the product data held in file PRODUCTS
and write them into the three 1D arrays.
Complete the pseudocode below.
OPEN ................................................................................................................................
i <-- 1
WHILE ..............................................................................................................................
READFILE ("PRODUCTS", ......................................................................................)
READFILE ("PRODUCTS", ......................................................................................)
READFILE ("PRODUCTS", ......................................................................................)
.......................................................................................................................................
.......................................................................................................................................
ENDWHILE
CLOSE "PRODUCTS"
OUTPUT "Product file contents written to arrays"
[5]
When Ahmed designed the PRODUCTS file, he considered the alternative file structure shown opposite.
It stores one product per line in the text file.

(ii) State one benefit and one drawback of this file design.
Benefit ...............................................................................................................................
...........................................................................................................................................
Drawback ..........................................................................................................................
.......................................................................................................................................[2]
(d) To code the ‘Search by product code’ procedure, Ahmed draws a structure chart showing the different stages.
The procedure uses the variables shown in the identifier table.
Identifier
Data type
Description
SearchCode
STRING
Product code input by the user
ThisIndex
INTEGER
Array index position for the corresponding product
ThisDescription
STRING
Product description found
ThisRetailPrice
REAL
Product retail price found
You can assume that before the procedure is run, all the product data is read from file
PRODUCTS and then stored in three 1D arrays as described in part (c)(i).
Label the structure chart to show the input(s) and output(s).

[4]
(e) A first attempt was made at writing the ‘Search for product code’ module.
Ahmed designs this as a function ProductCodeSearch. The function returns an integer value as follows:
• if the product code is found, it returns the index position of the 1D array PCode being searched
• if the product code is not found, the function returns -1
Write program code for function ProductCodeSearch.
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 ...................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
XX