9608/21/o/n/15 © Ucles 2015
9608/21/o/n/15 © Ucles 2015
 h   ←      13.6
 w   ←      6.4
 Perimeter           ←     (h + w) * 2                                                            (i) Perimeter …………………………………… [1]
 r   ←      10
 Area 3.142 * r^2                                                                                 (ii) Area ………………………………………………… [1]
2 A programmer uses an Integrated Development Environment (IDE) for all program development.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
     (ii)    Name three features you would expect to be available in an IDE to help initial error detection
             or debugging.
1 ...............................................................................................................................................
...................................................................................................................................................
2 ...............................................................................................................................................
...................................................................................................................................................
3 ...............................................................................................................................................
...............................................................................................................................................[3]
(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:
                                                   Product
                                                  processing
                                     By                               By                                  By
                                product code                       description                           price
         •     product code
         •     product description
         •     product retail price
The text file PRODUCTS stores each data item on a separate line, as shown below:
                                              File PRODUCTS
                                       0198
                                       Plums(10kg)
                                       11.50
                                       0202
                                       Onions(20kg)
                                       10.00
                                       0376
                                       Mango chutney(1kg)
                                       02.99
                                       0014
                                       Mango(10kg)
                                       12.75
         (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.
OPEN ................................................................................................................................
i 1
WHILE ..............................................................................................................................
.......................................................................................................................................
.......................................................................................................................................
ENDWHILE
CLOSE "PRODUCTS"
(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.
         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).
                                                        Lookup by
                                                       product code
                                                                                                 ......................
                                                                                  ......................
                   ......................
                                            .................
                                                                        ................            ......................
......................
[4]
    (e) A first attempt was made at writing the ‘Search for product code’ module.
        Ahmed designs this as a function ProductCodeSearch.
         •       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
         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.
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
3   (a) A multi-user computer system stores information about users. It uses a 1D array,
        UserNameArray, of type STRING. There are 100 elements in the array.
<UserID><UserName>
You should assume that UserNameArray has been declared as a global variable.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
    (b) The value of UserID should be unique for each user but a problem has occurred and
        repeated UserID values may have been issued.
         The array is sorted by UserID, so any repeated UserID values will appear in consecutive
         array elements.
This will:
         •     compare each element with the previous element and output the UserID and UserName
               if the UserID is repeated
         •     output the total number of UserIDs that are repeated.
122222Jim Moriarty
                        123456Fred Smith
                        123456Eric Sykes               Repeated User ID
                        123456Kevin Turvey             Repeated User ID
                        222244Alice Chan
                        222244Myra Singh               Repeated User ID
333333Yasmin Halim
                      123456Eric Sykes
                      123456Kevin Turvey
                      222244Myra Singh
                      There are 3 repeated UserIDs
         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.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
1 ........................................................................................................................................
2 ........................................................................................................................................
                3 ........................................................................................................................................
                                                                                                                                                      [3]
...........................................................................................................................................
.......................................................................................................................................[1]
(iii) Name two features provided by an IDE that assist in the program development cycle.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
                ...........................................................................................................................................
                                                                                                                                                       [2]
        (iv)    The procedure, FindRepeats, is written assuming there are 100 elements in
                UserNameArray.
                In the main program, the global array, UserNameArray, has been declared with only
                50 elements.
.......................................................................................................................................[1]
    You are required to write program code to test the random number generator of your chosen
    language.
    The program code should be written as a procedure. In pseudocode, the procedure heading will
    be:
    The parameter, Repetitions, contains a value representing the total number of random numbers
    that should be generated.
The following example shows the expected output for the procedure call, TestRandom(200).
         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.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
          ............................................................................................................................................ [16]
© UCLES 2017                                                      9608/22/O/N/17                                                           [Turn over
                                                                          12
(b) Name three features of a typical IDE that would help a programmer to debug a program.
         Explain how each of these could be used in the debugging of the TestRandom procedure
         from part (a).
Feature 1 ..................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [6]
    (c) The procedure is developed and run using the call TestRandom(200). No system errors
        are produced.
To ensure that the procedure works correctly, you need to check the output.
Describe two checks you should make to suggest the program works correctly.
1 ...............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ...............................................................................................................................................
...................................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [2]
2 (a) A student is learning about arrays. She wants to write a program to:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
(b) She uses the process of stepwise refinement to develop her algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
         She has been told that there are different file modes that can be used when opening a text
         file. She wants to make sure that the existing contents are not deleted when the file is opened.
Identify two file modes she could use and describe their use.
Mode .........................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Mode .........................................
Description ................................................................................................................................
...................................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [4]
    (d) The student has completed the design of her program and is ready to use an Integrated
        Development Environment (IDE).
Describe the features of an IDE that she can use to write, translate and test her program.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
2   (a) A structure chart is often used in modular program design. One feature shown is the sequence
        of module execution.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
...................................................................................................................................................
Feature 4 ..................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [4]
    (b) Identify and describe one feature of an Integrated Development Environment (IDE) that can
        help with program presentation.
Feature .....................................................................................................................................
Description ................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [2]
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
          ............................................................................................................................................. [2]
© UCLES 2019                                                      9608/21/O/N/19                                                           [Turn over
QUESTION 13.                                                               5
2 (a) Describe the program development cycle with reference to the following:
         •       source code
         •       object code
         •       corrective maintenance.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
    (b) Give three features of an Integrated Development Environment (IDE) that can help with
        initial error detection while writing the program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
          ...................................................................................................................................................
                                                                                                                                                         [3]