Question Paper 4
Question Paper 4
Refer to the insert for the list of pseudocode functions and operators.
(a) The algorithm for function Calculate() contains the three pseudocode
statements shown.
Describe the error in each statement or write ‘no error’ if the statement contains
no error. Assume any variables used are of the correct type for the given function.
Error ..........................................................................................................................
................
...................................................................................................................................
................
Error ..........................................................................................................................
................
...................................................................................................................................
................
Error ..........................................................................................................................
................
...................................................................................................................................................
[3]
[Turn over
2
Variable Value
Active TRUE
Points 75
Exempt FALSE
Expression Evaluation
[2]
(ii) Write expression 4 from the table in part (c)(i) in its simplest form.
............................................................................................................................
......... [1]
4
START
END
[4]
5
Declaration ...............................................................................................................
................
Assignment ...............................................................................................................
................
[3]
[Turn over
6
A program is used to manage the points system and the table lists some of the
information stored for one customer.
(a) (i) Identify a suitable structure for storing the information for one customer.
Explain the advantage of using this structure.
Structure ............................................................................................................
................
Advantage ..........................................................................................................
...............
............................................................................................................................
...............
............................................................................................................................
...............
............................................................................................................................
...............
............................................................................................................................
...............
...........................................................................................................................................
[4]
(ii) Describe a data structure that could be used to store the information for all
customers.
...........................................................................................................................................
..................................................................................................................................... [2]
7
(b) Customers receive points depending on the amount they spend. The number
of points depends on the band that the amount falls into:
For example, if the amount is $99.77, this amount is in band 2 and therefore the
number of points is 7 × 99, which is 693 points.
The algorithm to calculate the points from a given amount is expressed as follows:
• work out the appropriate band
• calculate and output the number of points.
Apply the process of stepwise refinement to increase the detail of the algorithm.
Structure your algorithm into a sequence of five steps that could be used to
produce pseudocode.
1 ................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
2 ................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
3 ................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
4 ................................................................................................................................
................
[Turn over
8
...................................................................................................................................
................
...................................................................................................................................
................
5 ................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................................
[5]
9
2. form a new string from the original string where all instances of the original
character are replaced by the new character
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
[Turn over
10
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
........... [6]
11
The array Sample consists of 6 rows by 128 columns and is of type integer. Each row
contains 128 digitised sound samples from one user.
The digitised sound samples from each user are to be processed to produce a single
value which will be stored in a 1D array Result of type integer. This process will be
implemented by procedure Mix().
Result: 20 20 35 40 46 25
[Turn over
12
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
13
.................
.........................................................................................................................................
.................
.........................................................................................................................................
.................
.........................................................................................................................................
........... [6]
[Turn over
14
6 A school has a computerised library system that allows students to borrow books for
a fixed length of time. The system uses text files to store details of students, books
and loans.
A new module is to be written which will generate emails to each student who has
an overdue book.
(a) Decomposition will be used to break down the problem of designing the new
module into sub-problems.
Identify three program modules that could be used in the design and describe their
use.
Module 1
...................................................................................................................................
Use ...........................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
Module 2
...................................................................................................................................
Use ...........................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
................
Module 3
...................................................................................................................................
Use ...........................................................................................................................
................
...................................................................................................................................
................
...................................................................................................................................
15
................
...................................................................................................................................................
[3]
[Turn over
16
BLANK PAGE
17
BLANK PAGE
18
BLANK PAGE