Pseudocode 2015
Pseudocode 2015
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (LK/JG) 95392/5
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 A marathon runner records their time for a race in hours, minutes and seconds.
(a) The identifier table needs to show the variables required to write a program for this algorithm.
[3]
The new design includes input of the runner’s current personal best marathon time (in
seconds).
The output will now also show one of the following messages:
(i) Show the additional variable needed for the new design.
[1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[7]
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
2 11053
3 11053
[6]
2 A program displays a menu with choices 1 to 4. The code to display the menu is written as the
procedure DisplayMenu.
CALL DisplayMenu
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
UNTIL Choice >= 1 AND Choice <= 4
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...........................................................................................................................................
.......................................................................................................................................[1]
CONSTANT i 3
CALL DisplayMenu
NoOfAttempts 0
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
NoOfAttempts NoOfAttempts + 1
UNTIL (Choice >= 1 AND Choice <= 4) OR NoOfAttempts = i
(i) Give the maximum number of inputs the user could be prompted to make.
............................................. [1]
(ii) State why this algorithm is an improvement on the one given in part (a).
...........................................................................................................................................
.......................................................................................................................................[1]
The table below shows the action currently taken by the pseudocode following each menu
choice.
Menu
Description Program response
choice
Read data from the Calls a procedure ReadFile which for testing
1
customer file purposes outputs the message “Read file code”
2 Add a customer Outputs message “Add customer code”
Complete the pseudocode for the design in part (b), shown again below, to respond to each
menu choice.
CONSTANT i 3
CALL DisplayMenu
NoOfAttempts 0
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
NoOfAttempts NoOfAttempts + 1
UNTIL (Choice >= 1 AND Choice <= 4) OR NoOfAttempts = i
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
Write program code for this final design which will be made up of:
• the main program
• procedure ReadFile
• procedure DisplayMenu
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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
© UCLES 2015 9608/21/M/J/15 [Turn over
8
3 When the guarantee on a computer runs out, the owner can take out insurance to cover breakdown
and repairs.
Following an enquiry to the insurance company, the customer receives a quotation letter with the
price of the insurance.
A program is to be produced.
The structure chart below shows the modular design for this process:
....................................
......................
......................
.........
...................... ...................... ......................
...................... .................
......................
......................
.................................... ....................................
Premium rates
Premium rates
(a) Using the letters A to D, add the labelling to the chart boxes on the opposite page.
Modules
A Send quotation letter
B Calculate price
C Produce insurance quotation
D Input computer details
[2]
(b) Using the letters E to J, complete the labelling on the chart opposite.
Data items
E CustomerName
F CustomerEmail
G Model
H Age
I PolicyCharge
J PolicyNumber
[4]
• they take turns at rolling a six-sided die (numbered 1 to 6) and record their throw
• a player scores 1 point if their throw is higher than their opponent
• they each roll the die 20 times
• if the player’s throw is the same as their opponent, the total points is unchanged
• the winner is the player with the larger number of points after 20 throws
FOR ....................................................................................................................................
INPUT Player1Throw
........................................................................................................................................
...............................................................................................................................
ENDIF
IF Player2Throw > Player1Throw
THEN
Player2Total Player2Total + 1
ENDIF
............................................................................................................................................
(ii) Identify the game result which will produce incorrect output.
...................................................................................................................................................
...............................................................................................................................................[1]
5 A company creates two new websites, Site X and Site Y, for selling bicycles.
These programs will use data about daily sales made from Site X (using variable SalesX) and
Site Y (using variable SalesY).
28 01/07/2015 14 8
...............................................................................................................................................[2]
(b) The programmer writes a program from the following pseudocode design.
x 0
FOR DayNumber 1 TO 7
IF SalesX[DayNumber] + SalesY[DayNumber] >= 10
THEN
x x + 1
OUTPUT SalesDate[DayNumber]
ENDIF
ENDFOR
OUTPUT x
(i) Trace the execution of this pseudocode by completing the trace table below.
x DayNumber OUTPUT
0
[4]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(c) The company wants a program to output the total monthly sales for one of the selected
websites.
The function returns the total number of bicycles sold for the given month and website.
MonthlyWebSiteSales(1, "Y")
MonthlyWebSiteSales(12, 'X')
[3]
(d) The company decides to offer a discount on selected dates. A program is written to indicate
the dates on which a discount is offered.
The program creates a text file, DISCOUNT_DATES (with data as shown), for a number of
consecutive dates.
03/06/2015 TRUE
04/06/2015 FALSE
05/06/2015 FALSE
06/06/2015 FALSE
07/06/2015 FALSE
08/06/2015 FALSE
09/06/2015 FALSE
10/06/2015 TRUE
11/06/2015 FALSE
01/07/2015 FALSE
The use of the square brackets indicates that the parameter is optional.
INPUT ......................................................................................................................................
INPUT Discount
INPUT NextDate
...................................................................................................................................................
CLOSEFILE [4]
(i) Add to the identifier table to show the variables you need for this new program.
[3]
Do not include any declaration or comment statements for the variables used.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[7]
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NF/JG) 112056/1
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 A marathon runner records their time for a race in hours, minutes and seconds.
(a) The identifier table needs to show the variables required to write a program for this algorithm.
[3]
The new design includes input of the runner’s current personal best marathon time (in
seconds).
The output will now also show one of the following messages:
(i) Show the additional variable needed for the new design.
[1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[7]
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
2 11053
3 11053
[6]
2 A program displays a menu with choices 1 to 4. The code to display the menu is written as the
procedure DisplayMenu.
CALL DisplayMenu
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
UNTIL Choice >= 1 AND Choice <= 4
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
...........................................................................................................................................
.......................................................................................................................................[1]
CONSTANT i 3
CALL DisplayMenu
NoOfAttempts 0
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
NoOfAttempts NoOfAttempts + 1
UNTIL (Choice >= 1 AND Choice <= 4) OR NoOfAttempts = i
(i) Give the maximum number of inputs the user could be prompted to make.
............................................. [1]
(ii) State why this algorithm is an improvement on the one given in part (a).
...........................................................................................................................................
.......................................................................................................................................[1]
The table below shows the action currently taken by the pseudocode following each menu
choice.
Menu
Description Program response
choice
Read data from the Calls a procedure ReadFile which for testing
1
customer file purposes outputs the message “Read file code”
2 Add a customer Outputs message “Add customer code”
Complete the pseudocode for the design in part (b), shown again below, to respond to each
menu choice.
CONSTANT i 3
CALL DisplayMenu
NoOfAttempts 0
REPEAT
OUTPUT "Enter choice (1..4)"
INPUT Choice
NoOfAttempts NoOfAttempts + 1
UNTIL (Choice >= 1 AND Choice <= 4) OR NoOfAttempts = i
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
Write program code for this final design which will be made up of:
• the main program
• procedure ReadFile
• procedure DisplayMenu
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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
© UCLES 2015 9608/22/M/J/15 [Turn over
8
3 When the guarantee on a computer runs out, the owner can take out insurance to cover breakdown
and repairs.
Following an enquiry to the insurance company, the customer receives a quotation letter with the
price of the insurance.
A program is to be produced.
The structure chart below shows the modular design for this process:
....................................
......................
......................
.........
...................... ...................... ......................
...................... .................
......................
......................
.................................... ....................................
Premium rates
Premium rates
(a) Using the letters A to D, add the labelling to the chart boxes on the opposite page.
Modules
A Send quotation letter
B Calculate price
C Produce insurance quotation
D Input computer details
[2]
(b) Using the letters E to J, complete the labelling on the chart opposite.
Data items
E CustomerName
F CustomerEmail
G Model
H Age
I PolicyCharge
J PolicyNumber
[4]
• they take turns at rolling a six-sided die (numbered 1 to 6) and record their throw
• a player scores 1 point if their throw is higher than their opponent
• they each roll the die 20 times
• if the player’s throw is the same as their opponent, the total points is unchanged
• the winner is the player with the larger number of points after 20 throws
FOR ....................................................................................................................................
INPUT Player1Throw
........................................................................................................................................
...............................................................................................................................
ENDIF
IF Player2Throw > Player1Throw
THEN
Player2Total Player2Total + 1
ENDIF
............................................................................................................................................
(ii) Identify the game result which will produce incorrect output.
...................................................................................................................................................
...............................................................................................................................................[1]
5 A company creates two new websites, Site X and Site Y, for selling bicycles.
These programs will use data about daily sales made from Site X (using variable SalesX) and
Site Y (using variable SalesY).
28 01/07/2015 14 8
...............................................................................................................................................[2]
(b) The programmer writes a program from the following pseudocode design.
x 0
FOR DayNumber 1 TO 7
IF SalesX[DayNumber] + SalesY[DayNumber] >= 10
THEN
x x + 1
OUTPUT SalesDate[DayNumber]
ENDIF
ENDFOR
OUTPUT x
(i) Trace the execution of this pseudocode by completing the trace table below.
x DayNumber OUTPUT
0
[4]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(c) The company wants a program to output the total monthly sales for one of the selected
websites.
The function returns the total number of bicycles sold for the given month and website.
MonthlyWebSiteSales(1, "Y")
MonthlyWebSiteSales(12, 'X')
[3]
(d) The company decides to offer a discount on selected dates. A program is written to indicate
the dates on which a discount is offered.
The program creates a text file, DISCOUNT_DATES (with data as shown), for a number of
consecutive dates.
03/06/2015 TRUE
04/06/2015 FALSE
05/06/2015 FALSE
06/06/2015 FALSE
07/06/2015 FALSE
08/06/2015 FALSE
09/06/2015 FALSE
10/06/2015 TRUE
11/06/2015 FALSE
01/07/2015 FALSE
The use of the square brackets indicates that the parameter is optional.
INPUT ......................................................................................................................................
INPUT Discount
INPUT NextDate
...................................................................................................................................................
CLOSEFILE [4]
(i) Add to the identifier table to show the variables you need for this new program.
[3]
Do not include any declaration or comment statements for the variables used.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[7]
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (LK/JG) 95389/4
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
1 Horses are entered for a horse race. A horse may have to carry a penalty weight in addition to the
rider. This weight is added to the saddle. The penalty weight (if any) depends on the number of
wins the horse has achieved in previous races.
(a) Complete the identifier table showing the variables needed to code the program.
[3]
(b) Line 3 in the algorithm above does not give the detail about how the race penalty weight is
calculated; this step in the algorithm must be expressed in more detail.
(i) The algorithm above currently has five stages. One technique for program design is to
further break down, where required, any stage to a level of detail from which the program
code can be written.
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
2 (a) Two operators available in a programming language are DIV and MOD. They perform integer
arithmetic as follows:
Expression Explanation
X DIV Y Computes the number of times Y divides into X
Calculate the value of the variables shown for the following code fragments.
Code Variable
(i) NumberLeftOver 37 MOD 10
NumberLeftOver ..................
[1]
(ii) Quantity 208
BoxSize 100
(b) Bank customers withdraw money from their account at a cash dispenser machine using their
bank card. The machine operates as follows:
When a customer withdraws money, they enter the amount to withdraw. (This must be a
multiple of $10).
The machine will always dispense the least possible number of notes.
Temp INTEGER Used in the calculation of the number of each note required
Complete the test data table showing the expected results with comments.
85
130
600
[3]
INPUT ..................................................................................................................................
IF Amount > 500
THEN
OUTPUT "Refused – amount too large"
ELSE
..................................................................................................................................
THEN
OUTPUT "Refused - not a multiple of $10"
ELSE
FiftyDollar Amount DIV 50
Temp ....................................................................................................
TwentyDollar ....................................................................................
Temp .....................................................................................................
.....................................................................................................................
ENDIF
ENDIF
[5]
3 A flooring company provides for each customer an estimated price for a new job. Each job is
given a Job ID.
The job cost is calculated from the length (nearest metre) and width (nearest metre) of the room.
• the floor area is calculated with 18% added to allow for wastage
• the job cost is calculated at $50 per square metre
The structure chart shows the modular design for a program to produce a new job cost.
Produce flooring
job cost
Length
B D JobID
A
JobCost E
Width
CustomerName
(i) Give the data items corresponding to the labels A to E in the structure chart.
A ....................................................................................................................................
B ....................................................................................................................................
C ....................................................................................................................................
D ....................................................................................................................................
E ....................................................................................................................................
[5]
(ii) The procedure below is one of the modules shown on the structure chart.
...............................................................................................
...............................................................................................
............................................................................................ )
ENDPROCEDURE
[5]
The use of the square brackets indicates that the parameter is optional.
.......................................................................................................................................[2]
(b) A country has a number of banks. There are cash dispensers all over the country. Each bank
is responsible for a number of dispensers.
It has one line of text for each dispenser. For example: 00342▼007.
This line in the file is the data for dispenser 00342 which belongs to bank 007.
For the creation of the file, data is entered by the user at the keyboard.
...............................................................................................................................................
............................................................................................................................
ENDIF
UNTIL ..................................................................................................................................
...............................................................................................................................................
(ii) No attempt has been made to validate the data entered by the user.
Describe two different types of validation check for the data entry.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
.......................................................................................................................................[2]
(iii) The programmer coded this algorithm above and the user successfully entered 15
dispenser records into the text file.
State the error that will occur if the user runs the program a second time for further data
entry.
.......................................................................................................................................[1]
(iv) Give the ‘file mode’ available in the programming language which will be used to address
this issue.
.......................................................................................................................................[1]
© UCLES 2015 9608/23/M/J/15 [Turn over
10
(c) The complete data file is created with the structure shown.
00024▼002
00025▼003
An example of a run of the program is shown: 00026▼007
00027▼007
00028▼102
Enter bank code 007
00001
00011
00022 99867▼013
00026
00027
Write the program code. Do not attempt to include any validation checks.
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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................[10]
5 A firm employs workers who assemble amplifiers. Each member of staff works an agreed number
of hours each day.
The firm records the number of completed amplifiers made by each employee each day.
Daily hours
worked Production data
Worker 1 5 Worker 1 Worker 2 Worker 3
Worker 2 10 Day 1 10 20 9
Worker 3 10 Day 2 11 16 11
Day 3 10 24 13
Day 4 14 20 17
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
.......................................................................................................................................[2]
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[2]
(b) Complete the trace table for the pseudocode algorithm below.
FOR WorkerNum 1 TO 3
WorkerTotal[WorkerNum] 0
ENDFOR
FOR WorkerNum 1 TO 3
FOR DayNum 1 TO 4
WorkerTotal[WorkerNum] WorkerTotal[WorkerNum] +
ProductionData[DayNum, WorkerNum]
ENDFOR
ENDFOR
FOR WorkerNum 1 TO 3
WorkerAverage WorkerTotal[WorkerNum]/
(4 * DailyHoursWorked[WorkerNum])
IF WorkerAverage < 2
THEN
OUTPUT “Investigate“, WorkerNum
ENDIF
ENDFOR
WorkerTotal
WorkerNum DayNum WorkerAverage OUTPUT 1 2 3
[8]
(c) An experienced programmer suggests that the pseudocode would be best implemented as a
procedure AnalyseProductionData.
Assume that both arrays, DailyHoursWorked and ProductionData, are available to the
procedure from the main program and they are of the appropriate size.
DECLARE ........................................................................................................................................
DECLARE ...................................................................................................................................... .
DECLARE ....................................................................................................................................... .
DECLARE ...................................................................................................................................... .
FOR WorkerNum 1 TO 3
WorkerTotal[WorkerNum] 0
ENDFOR
FOR WorkerNum 1 TO 3
FOR DayNum 1 TO 4
WorkerTotal[WorkerNum] WorkerTotal[WorkerNum] +
ProductionData[DayNum, WorkerNum]
ENDFOR
ENDFOR
FOR WorkerNum 1 TO 3
WorkerAverage WorkerTotal[WorkerNum]/
(4 * DailyHoursWorked [WorkerNum])
IF WorkerAverage < 2
THEN
OUTPUT "Investigate", WorkerNum
ENDIF
ENDFOR
ENDPROCEDURE
(i) Complete the declaration statements showing the local variables. [4]
(ii) The original pseudocode has been ‘pasted’ under the procedure header.
Circle all the places in the original pseudocode where changes will need to be made.
Write the changes which need to be made next to each circle. [3]
(iii) Write the statement for a procedure call which processes data for 7 days for 13 workers.
.......................................................................................................................................[1]
BLANK PAGE
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NH/CGW) 95372/4
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
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]
• The gate has two inputs (TRUE or FALSE) which are entered by the user.
• The program will display the output (TRUE or FALSE) from the gate.
01 INPUT InA
02 INPUT InB
03 IF (InA = FALSE AND InB = FALSE) OR (InA = FALSE AND InB = TRUE)
OR (InA = TRUE AND InB = FALSE)
04 THEN
05 OutZ ← TRUE
06 ELSE
07 OutZ ← FALSE
08 ENDIF
09 OUTPUT OutZ
Input Output
Test case InA InB OutZ
1 TRUE TRUE
2 TRUE FALSE
3 FALSE TRUE
4 FALSE FALSE
[4]
(b) The selection statement (lines 03 – 08) could have been written with more simplified logic.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
A purchase may qualify for a discount depending on the amount spent. The purchase price
(Purchase), the discount rate (DiscountRate) and amount paid (Paid) is calculated as shown
in the following pseudocode algorithm.
INPUT Purchase
Paid ←
Purchase * (1 - DiscountRate)
OUTPUT Paid
[6]
The value of the car reduces each year by a percentage of its current value.
The driver writes a program to predict the value of the car in future years.
(a) Study the incomplete pseudocode which follows in part (b) and fill in the identifier table.
[3]
CurrentValue ← ......................................................................................................
YearCount 1 ←
WHILE ....................................... AND .........................................................................
IF ............................................................................................................................
THEN
CurrentValue ← CurrentValue * (1 – 40 / 100)
ELSE
CurrentValue ← ......................................................................................
ENDIF
...................................................................................................................................
ENDWHILE
[6]
6 A firm employs five staff who take part in a training programme. Each member of staff must
complete a set of twelve tasks which can be taken in any order. When a member of staff
successfully completes a task, this is recorded.
A program is to be produced to record the completion of tasks for the five members of staff.
To test the code, the programmer makes the program generate test data.
Each pair of numbers simulates the completion of one task by one member of staff.
(a) Explain why the generation of 60 (5 staff x 12 tasks) pairs of random numbers will not simulate
all tasks completed by all staff.
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
The table shows that two members of staff have each successfully completed one task.
The program must use a suitable data structure to store, for all staff:
The program will output the staff number and task number in the order in which tasks are
completed.
(iii) The incrementing of a variable used as a counter, but not to control a ‘count controlled’
loop.
.................... [1]
.................... [1]
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(iv) Give the global variable that needs to be declared at line 03.
.......................................................................................................................................[2]
(d) Line 17 in the pseudocode outputs the staff number and the task number.
Staff number Staff name
A new requirement is to display the name of the
member of staff given in the table. 1 Sadiq
2 Smith
Write a CASE structure using variable StaffNum. 3 Ho
Assign to a new variable StaffName the appropriate 4 Azmah
staff name. 5 Papadopoulos
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
Some pseudocode statements follow which use the built-in functions below:
Num1 ← 15
A ← CHR(67) & CHR(65) & CHR(84) (i) A ..................................................... [1]
B ← ASC('P') - ASC('F') + 3 (ii) B ..................................................... [1]
C ← ASC(ONECHAR("BISCUITS", 3)) (iii) C ..................................................... [1]
D ← CHARACTERCOUNT("New York City") + 2 (iv) D ..................................................... [1]
(b) A program is to be written which accepts a string and then calculates a numeric value from
this string. The input string and the calculated value are then to be sent to a remote computer
over a communications link.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
(c) Explain the purpose of sending the value of StringTotal to the remote computer, in
addition to MyString.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
8 In this question you will need to use the given pseudocode built-in function:
A program reads a string entered by the user. The string represents the addition or subtraction
of two fractions. Each part of the fraction within the string is always a single digit only and the
top digit is always less than the bottom digit.
Op
é
N4Char
N3Char
N2Char
N1Char
The identifier table shows the variables to be used to store the characters in the string as
shown in the diagram.
FractionString ← "3/7+2/9"
N3Char ← ONECHAR(FractionString, 5) (i) N3Char .................................... [1]
Op ← ONECHAR(FractionString, 4) (ii) Op .............................................. [1]
(iii) Complete the function call to isolate the character '9' from FractionString.
FractionString ← "3/7+2/9"
Complete the three dry runs for the three given values of FractionString.
BottomAnswer ← N2 * N4
Op ← ONECHAR(FractionString, 4)
IF Op = '+'
THEN
// add fractions
TopAnswer ←
(BottomAnswer / N2) * N1 + (BottomAnswer / N4) * N3
ELSE
// subtract fractions
TopAnswer ←
(BottomAnswer / N2) * N1 - (BottomAnswer / N4) * N3
ENDIF
IF TopAnswer = BottomAnswer
THEN
OUTPUT '1'
ELSE
IF TopAnswer > BottomAnswer
THEN
TopAnswer ←
TopAnswer MOD BottomAnswer
// the & operator joins strings or character values
OUTPUT "1 " & TOSTR(TopAnswer) & "/" & TOSTR(BottomAnswer)
ELSE
OUTPUT TOSTR(TopAnswer) & "/" & TOSTR(BottomAnswer)
ENDIF
ENDIF
[2]
[2]
[3]
(d) The programmer writes code from the given pseudocode design. The program works, but the
design is limited.
.......................................................................................................................................[1]
(ii) Describe three specification changes which will make the program more useful.
1 .......................................................................................................................................
...........................................................................................................................................
2 .......................................................................................................................................
...........................................................................................................................................
3 .......................................................................................................................................
.......................................................................................................................................[3]
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NH/CGW) 95376/4
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
DECLARE N1 : INTEGER
DECLARE N2 : INTEGER
DECLARE Answer : REAL
DECLARE Found : BOOLEAN
DECLARE IsValid : BOOLEAN
N1 ← 3
N2 ← 9
Answer ← (N1 + N2) / 6
Answer ← 3 * (N1 – 2) + N2 / 2
IsValid ← (N1 > N2) AND (N2 = 9)
Found ← FALSE
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
© UCLES 2015 9608/22/O/N/15
3
• The gate has two inputs (0 or 1) which are entered by the user.
• The program will display the output (0 or 1) from the gate.
01 INPUT P
02 INPUT Q
03 IF (P = 1 AND Q = 0) OR (P = 0 AND Q = 1) OR (P = 0 AND Q = 0)
04 THEN
05 X 0 ←
06 ELSE
07 X 1 ←
08 ENDIF
09 OUTPUT X
Input Output
Test case P Q X
1 1 1
2 1 0
3 0 1
4 0 0
[4]
(b) The selection statement (lines 03 – 08) could have been written with more simplified logic.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
Points are calculated from every transaction and added to the points total stored on the card.
When the points total exceeds 500, the customer can either:
• pay the full amount due and increase their points total
• get $1 deducted from the amount due in exchange for 500 reward points
The new points total and amount to be paid is printed on the receipt.
A user-defined function CalculatePoints has already been coded to calculate the new points
earned from the amount spent.
INPUT AmountDue
NewPoints ← CalculatePoints(AmountDue)
PointsTotal ←
PointsTotal + NewPoints
CALL
CalculatePoints(AmountDue)
[6]
© UCLES 2015 9608/22/O/N/15 [Turn over
6
4 The standard pack of playing cards has four suits – called Clubs, Diamonds, Hearts and Spades.
Each card has a value shown by its number or a name: 1 (Ace), 2, 3, … 10, 11 (Jack), 12 (Queen),
13 (King). The pack of cards has one combination for each suit and value.
A program is to be written which simulates a magician dealing all 52 cards from the card pack.
(a) Explain why the generation of 52 (4 suits x 13 card values) pairs of random numbers will not
simulate the dealing of the complete pack.
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
Card value
Suit
number 1 2 3 4 5 6 7 8 9 10 11 12 13
1 (Clubs) F F F F F F F F F F T F F
2 (Diamonds) F F F F F F F F F F F F F
3 (Hearts) F F T F F F F F F F F F F
4 (Spades) F F F F F F F F F F F F F
The table shows two cards have been dealt so far; the 3 of Hearts and the Jack of Clubs.
The program will output the suit and the card value in the order in which the cards are dealt.
.......................................................................................................................................[1]
.......................................................................................................................................[1]
(iii) The initialisation of a variable used as a counter, but not to control a ‘count controlled’
loop.
.......................................................................................................................................[1]
.......................................................................................................................................[1]
...............................................................................................................................................[1]
...............................................................................................................................................[1]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(g) Line 18 in the design shows which new card is dealt each time.
When an Ace, Jack, Queen or King is dealt, the output displays the number for that card, not
the name of the card.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
The integers are stored in an array, Num. The first N elements are to be processed.
FOR i ←1 TO (N - 1)
j ←
1
REPEAT
IF Num[j] > Num[j + 1]
THEN
Temp ←
Num[j]
Num[j] ←
Num[j + 1]
Num[j + 1] Temp ←
ENDIF
j ←
j + 1
UNTIL j = (N – i + 1)
ENDFOR
(a) (i) Trace the execution of the pseudocode for the value N = 5 and the given array of integers.
Num
N i j Temp 1 2 3 4 5
5 11 16 13 7 8
[8]
...........................................................................................................................................
.......................................................................................................................................[1]
(iii) Describe what evidence from the trace table suggests that the given pseudocode is
inefficient.
...........................................................................................................................................
.......................................................................................................................................[1]
(b) Complete the identifier table documenting the use of each of the variables.
Temp
[5]
6 Some pseudocode statements follow which use the following built-in functions:
NewString ""←
INPUT InputString
j ← CHARACTERCOUNT(InputString)
FOR i ←
1 TO j
NextChar ←
ONECHAR(InputString, i)
IF NextChar <> " "
THEN
// the & character joins together two strings
NewString ←
NewString & NextChar
ENDIF
ENDFOR
OUTPUT NewString
[4]
© UCLES 2015 9608/22/O/N/15 [Turn over
14
The function:
• has identifier RemoveSpaces
• has a single parameter
• will include the declaration for any local variables used by the function
// main program
INPUT MyString
ChangedString ← RemoveSpaces(.........................................................................................)
OUTPUT ChangedString
// function definition
.................................................................................................................................................
.................................................................................................................................................
.................................................................................................................................................
.................................................................................................................................................
j ← CHARACTERCOUNT(InputString)
FOR i ← 1 TO j
NextChar ← ONECHAR(InputString, i)
IF NextChar <> " "
THEN
// the & character joins together two strings
NewString ← NewString & NextChar
ENDIF
ENDFOR
.................................................................................................................................................
ENDFUNCTION
[7]
Num1 ← 5
A ← ASC('F') + Num1 + ASC('Z') (i) A ..................................................... [1]
B ← CHR(89) & CHR(69) & CHR(83) (ii) B ..................................................... [1]
C ← CHARACTERCOUNT(B & "PLEASE") (iii) C ..................................................... [1]
D ← ASC(ONECHAR("CURRY SAUCE", 7)) (iv) D ..................................................... [1]
(b) A program is to be written to input a message string and then encrypt the message.
OUTPUT EncryptString
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.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[8]
(ii) Describe the encryption algorithm used to encrypt the message string entered by the
user.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
© UCLES 2015 9608/22/O/N/15
Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level
* 4 5 3 1 9 9 0 1 8 1 *
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (GB) 116769
© UCLES 2015 [Turn over
2
Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to indicate which high-level programming language you will use.
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]
• The gate has two inputs (TRUE or FALSE) which are entered by the user.
• The program will display the output (TRUE or FALSE) from the gate.
01 INPUT InA
02 INPUT InB
03 IF (InA = FALSE AND InB = FALSE) OR (InA = FALSE AND InB = TRUE)
OR (InA = TRUE AND InB = FALSE)
04 THEN
05 OutZ ← TRUE
06 ELSE
07 OutZ ← FALSE
08 ENDIF
09 OUTPUT OutZ
Input Output
Test case InA InB OutZ
1 TRUE TRUE
2 TRUE FALSE
3 FALSE TRUE
4 FALSE FALSE
[4]
(b) The selection statement (lines 03 – 08) could have been written with more simplified logic.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
A purchase may qualify for a discount depending on the amount spent. The purchase price
(Purchase), the discount rate (DiscountRate) and amount paid (Paid) is calculated as shown
in the following pseudocode algorithm.
INPUT Purchase
Paid ←
Purchase * (1 - DiscountRate)
OUTPUT Paid
[6]
The value of the car reduces each year by a percentage of its current value.
The driver writes a program to predict the value of the car in future years.
(a) Study the incomplete pseudocode which follows in part (b) and fill in the identifier table.
[3]
CurrentValue ← ......................................................................................................
YearCount 1 ←
WHILE ....................................... AND .........................................................................
IF ............................................................................................................................
THEN
CurrentValue ← CurrentValue * (1 – 40 / 100)
ELSE
CurrentValue ← ......................................................................................
ENDIF
...................................................................................................................................
ENDWHILE
[6]
6 A firm employs five staff who take part in a training programme. Each member of staff must
complete a set of twelve tasks which can be taken in any order. When a member of staff
successfully completes a task, this is recorded.
A program is to be produced to record the completion of tasks for the five members of staff.
To test the code, the programmer makes the program generate test data.
Each pair of numbers simulates the completion of one task by one member of staff.
(a) Explain why the generation of 60 (5 staff x 12 tasks) pairs of random numbers will not simulate
all tasks completed by all staff.
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
The table shows that two members of staff have each successfully completed one task.
The program must use a suitable data structure to store, for all staff:
The program will output the staff number and task number in the order in which tasks are
completed.
(iii) The incrementing of a variable used as a counter, but not to control a ‘count controlled’
loop.
.................... [1]
.................... [1]
.......................................................................................................................................[1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
(iv) Give the global variable that needs to be declared at line 03.
.......................................................................................................................................[2]
(d) Line 17 in the pseudocode outputs the staff number and the task number.
Staff number Staff name
A new requirement is to display the name of the
member of staff given in the table. 1 Sadiq
2 Smith
Write a CASE structure using variable StaffNum. 3 Ho
Assign to a new variable StaffName the appropriate 4 Azmah
staff name. 5 Papadopoulos
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
Some pseudocode statements follow which use the built-in functions below:
Num1 ← 15
A ← CHR(67) & CHR(65) & CHR(84) (i) A ..................................................... [1]
B ← ASC('P') - ASC('F') + 3 (ii) B ..................................................... [1]
C ← ASC(ONECHAR("BISCUITS", 3)) (iii) C ..................................................... [1]
D ← CHARACTERCOUNT("New York City") + 2 (iv) D ..................................................... [1]
(b) A program is to be written which accepts a string and then calculates a numeric value from
this string. The input string and the calculated value are then to be sent to a remote computer
over a communications link.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
(c) Explain the purpose of sending the value of StringTotal to the remote computer, in
addition to MyString.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
8 In this question you will need to use the given pseudocode built-in function:
A program reads a string entered by the user. The string represents the addition or subtraction
of two fractions. Each part of the fraction within the string is always a single digit only and the
top digit is always less than the bottom digit.
Op
é
N4Char
N3Char
N2Char
N1Char
The identifier table shows the variables to be used to store the characters in the string as
shown in the diagram.
FractionString ← "3/7+2/9"
N3Char ← ONECHAR(FractionString, 5) (i) N3Char .................................... [1]
Op ← ONECHAR(FractionString, 4) (ii) Op .............................................. [1]
(iii) Complete the function call to isolate the character '9' from FractionString.
FractionString ← "3/7+2/9"
Complete the three dry runs for the three given values of FractionString.
BottomAnswer ← N2 * N4
Op ← ONECHAR(FractionString, 4)
IF Op = '+'
THEN
// add fractions
TopAnswer ←
(BottomAnswer / N2) * N1 + (BottomAnswer / N4) * N3
ELSE
// subtract fractions
TopAnswer ←
(BottomAnswer / N2) * N1 - (BottomAnswer / N4) * N3
ENDIF
IF TopAnswer = BottomAnswer
THEN
OUTPUT '1'
ELSE
IF TopAnswer > BottomAnswer
THEN
TopAnswer ←
TopAnswer MOD BottomAnswer
// the & operator joins strings or character values
OUTPUT "1 " & TOSTR(TopAnswer) & "/" & TOSTR(BottomAnswer)
ELSE
OUTPUT TOSTR(TopAnswer) & "/" & TOSTR(BottomAnswer)
ENDIF
ENDIF
[2]
[2]
[3]
(d) The programmer writes code from the given pseudocode design. The program works, but the
design is limited.
.......................................................................................................................................[1]
(ii) Describe three specification changes which will make the program more useful.
1 .......................................................................................................................................
...........................................................................................................................................
2 .......................................................................................................................................
...........................................................................................................................................
3 .......................................................................................................................................
.......................................................................................................................................[3]
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.