Computer Science (9608) · Oct/Nov 2019 · Question paper 42

Cambridge Computer Science (9608) question paper for paper 42, Oct/Nov 2019 — 9608/42/O/N/19, file 9608_w19_qp_42.pdf.

Advertisement
Loading the paper…
Text of this paper

www.dynamicpapers.com

Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level

* 4 4 6 1 3 8 8 7 1 2 *

9608/42

COMPUTER SCIENCE
Paper 4 Further Problem-solving and Programming Skills

October/November 2019
2 hours

Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.
READ THESE INSTRUCTIONS FIRST
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.
Answer all questions.
No marks will be awarded for using brand names of software packages or hardware.
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.
The maximum number of marks is 75.

This document consists of 17 printed pages and 3 blank pages.
DC (LEG/FC) 168337/3
© UCLES 2019

[Turn over

www.dynamicpapers.com

2
1

A technology company needs software to calculate how much each employee should be paid.
(a) Developing the software will involve the following activities:
Activity

(i)

Description

Time to
complete
(weeks)

Predecessor

A

Identify requirements

1

–

B

Observe current system

1

A

C

Create algorithm design

3

B

D

Write code

10

C

E

Test modules

7

C

F

White box testing

2

D

G

Black box testing

3

D

H

Install software

1

E, F, G

I

Acceptance testing

2

H

J

Create user documentation

2

H

Add the correct activities and times to the following Program Evaluation Review
Technique (PERT) chart for the software development.
Three of the activities and times have been done for you.
5

1

A
1

2

3

4

8

2 F

6
7

9
2
11

I
10
[7]

© UCLES 2019

9608/42/O/N/19

www.dynamicpapers.com

3
(ii)

The dashed line connecting nodes 10 and 11 indicates a dummy activity.
State the purpose of a dummy activity.

[1]

(b) A bonus payment may be added to an employee’s salary. A pension payment may also be
subtracted from an employee’s salary.
The company needs to assess what additions and subtractions should be made to the salary
of each employee. There are three conditions to check:

•
•
•

If the employee has worked a public holiday, they receive a 3% bonus payment.
If the employee has worked 160 or more hours in a month, they receive an additional 5%
bonus payment.
If the employee pays into a pension, the company subtracts 4% for the pension payment.

Complete the decision table to show the additions and subtractions.
Rules
Conditions

Public holiday

Y

Y

Y

Y

N

N

N

N

Hours >= 160

Y

Y

N

N

Y

Y

N

N

Pension

Y

N

Y

N

Y

N

Y

N

3% bonus payment
Actions

5% bonus payment
4% pension payment

© UCLES 2019

[3]

9608/42/O/N/19

[Turn over

www.dynamicpapers.com

4

(c) The company decides to implement a program for the software using object-oriented
programming (OOP).
Each employee has a unique employee ID, name, address and date of birth. There are two
types of employee: salary and apprenticeship.
Salaried employees are paid a fixed monthly payment. The hours a salary employee works in
a month are recorded to calculate bonus payments. They may receive bonus payments and
make pension payments (given in part(b)).
Apprenticeship employees are paid weekly. They receive an hourly rate of pay. Apprenticeship
employees do not receive bonus payments or make pension payments.
(i)

Complete the following class diagram for the program.
Employee
EmployeeID : STRING
Name : STRING

Address : STRING

DateOfBirth : Date
Constructor()

GetEmployeeID()
GetName()

GetAddress()

GetDateOfBirth()
SetEmployeeID()
SetName()

SetAddress()

SetDateOfBirth()
SalaryEmployee

ApprenticeshipEmployee

MonthlyPayment : CURRENCY

HoursThisMonth: REAL

PublicHoliday : BOOLEAN

Pension : BOOLEAN
Constructor()

GetMonthlyPayment()
GetHoursThisMonth()

GetPublicHoliday()

GetHourlyRate()

GetPension()

GetHoursThisWeek()

SetMonthlyPayment()

SetHourlyRate()

SetHoursThisMonth()
SetPublicHoliday()
SetPension()
© UCLES 2019

[3]
9608/42/O/N/19

5
(ii)

www.dynamicpapers.com

Write program code for the Constructor() in the Employee class.
All properties are sent as parameters.
Programming language
Program code

[4]

(iii)

Write program code for the GetEmployeeID()method in the Employee class.
The get method returns the value of the EmployeeID property.
Programming language
Program code

[2]

© UCLES 2019

9608/42/O/N/19

[Turn over

6
(iv)

www.dynamicpapers.com

Write program code for the SetEmployeeID()method in the Employee class.
The set method takes the new value as its parameter.
Programming language
Program code

[2]

(v)

Write program code for the SetPension()method in the SalaryEmployee()class.

•
•
•

The method takes a new value for Pension as a parameter.
If the parameter’s value is valid (it is TRUE or FALSE), the method returns TRUE and
sets the parameter’s value.
Otherwise the method returns FALSE and does not set Pension.

Programming language
Program code

[4]

© UCLES 2019

9608/42/O/N/19

7

www.dynamicpapers.com

Question 1 continues on the next page.

© UCLES 2019

9608/42/O/N/19

[Turn over

8
(vi)

www.dynamicpapers.com

A SalaryEmployee is paid a fixed monthly payment.

•
•
•

If the employee has worked a public holiday, they receive a 3% bonus payment.
This is calculated from their MonthlyPayment.
If the employee has worked 160 or more hours in a month, they receive an additional
5% bonus payment, calculated from their MonthlyPayment.
If the employee pays into a pension, 4% will be subtracted from their
MonthlyPayment.

Monthly salary is the final payment the employee receives.
For example, Chris is a SalaryEmployee. His fixed MonthlyPayment is $1000. He has
worked a public holiday. He has worked 165 hours this month. He pays into a pension.

•
•
•

The public holiday bonus is $30 (3% of $1000)
The hours worked bonus payment is $50 (5% of $1000)
The pension payment is $40 (4% of $1000)

Chris’s monthly salary is calculated as ($1000 + $30 + $50) − $40 = $1040
The function CalculateMonthlySalary()is used to calculate the monthly salary. It:

•
•
•
•

takes a SalaryEmployee as a parameter
calculates the bonus payments and pension payment
outputs the pension payment and total bonus payment
calculates and returns the monthly salary.

Write program code for the function CalculateMonthlySalary().
Programming language
Program code

© UCLES 2019

9608/42/O/N/19

9

www.dynamicpapers.com

[8]
© UCLES 2019

9608/42/O/N/19

[Turn over

10

www.dynamicpapers.com

(d) Noona describes an example of a feature of object-oriented programming (OOP). She says:
“One method exists in the parent class but is overwritten in the child class, to behave
differently.”
Identify the feature Noona has described.
[1]
2

The number of cars that cross a bridge is recorded each hour. This number is placed in a circular
queue before being processed.
(a) The queue is stored as an array, NumberQueue, with eight elements. The function
AddToQueue adds a number to the queue. EndPointer and StartPointer are global
variables.
Complete the following pseudocode algorithm for the function AddToQueue.
FUNCTION AddToQueue(Number : INTEGER) RETURNS BOOLEAN
DECLARE TempPointer : INTEGER
CONSTANT FirstIndex = 0
CONSTANT LastIndex =
TempPointer

EndPointer + 1

IF > LastIndex
THEN
TempPointer

ENDIF
IF TempPointer = StartPointer
THEN
RETURN
ELSE
EndPointer

TempPointer

NumberQueue[EndPointer]

RETURN TRUE
ENDIF
ENDFUNCTION
© UCLES 2019

[5]
9608/42/O/N/19

11

www.dynamicpapers.com

(b) Describe how a number is removed from the circular queue to be processed.

[4]
(c) A queue is one example of an Abstract Data Type (ADT).
Identify three other Abstract Data Types.
1
2
3
[3]

© UCLES 2019

9608/42/O/N/19

[Turn over

12
3

www.dynamicpapers.com

A company wants to test a program to check that it works. They can use different types of test
data to do this.
(a) Identify three different types of test data that the company can use.
1
2
3
[3]
(b) The programmer will make use of debugging features, when building and testing a program.
(i)

Two debugging features are described in the table.
Write the correct name for each debugging feature.
Description

Name of debugging feature

A point where the program can be halted to
see if the program works to this point.
One statement is executed and then the
program waits for input from the programmer
to move on to the next statement.

[2]

(ii)

Identify and describe one other debugging feature.
Debugging feature
Description

[2]

© UCLES 2019

9608/42/O/N/19

www.dynamicpapers.com

13
4

A bank wants to analyse how an automated teller machine (ATM) deals with transactions.
The following state-transition table shows the transitions from one state to another for a transaction.
Current state

Event

Next state

ATM active

Insert card

Waiting for PIN

Waiting for PIN

Enter PIN

Checking PIN

Waiting for PIN

Cancel selected

Transaction cancelled

Checking PIN

PIN valid

Account accessed

Checking PIN

PIN invalid

Waiting for PIN

Account accessed

Cancel selected

Transaction cancelled

Account accessed

Input amount to withdraw

Checking account

Checking account

Funds available

Transaction complete

Transaction complete

Return card and dispense cash

ATM active

Checking account

Funds not available

Account accessed

Transaction cancelled

Return card

ATM active

Complete the state-transition diagram to correspond with the table.
Start

Insert card

ATM
active

Waiting
for PIN

Transaction
complete

Transaction
cancelled

Checking
account

Enter PIN

Checking
PIN

Account
accessed

Input amount to withdraw
[8]

© UCLES 2019

9608/42/O/N/19

[Turn over

14
5

www.dynamicpapers.com

The following table shows part of the instruction set for a processor which has one general purpose
register, the Accumulator (ACC) and an Index Register (IX).
Instruction

Op code

Explanation

Operand

LDM #n

Immediate addressing. Load the number n to ACC.

LDD <address>

Direct addressing. Load the contents of the location at the given address to
ACC.

LDI <address>

Indirect addressing. The address to be used is at the given address. Load
the contents of this second address to ACC.

LDX <address>

Indexed addressing. Form the address from <address> + the contents of
the Index Register. Copy the contents of this calculated address to ACC.

LDR #n

Immediate addressing. Load the number n to IX.

STO <address>

Store the contents of ACC at the given address.

STX <address>

Indexed addressing. Form the address from <address> + the contents of
the Index Register. Copy the contents from ACC to this calculated address.

ADD <address>

Add the contents of the given address to the ACC.

INC <register>
DEC <register>
JMP <address>
CMP <address>
CMP #n

Add 1 to the contents of the register (ACC or IX).
Subtract 1 from the contents of the register (ACC or IX).
Jump to the given address.
Compare the contents of ACC with the contents of <address>.
Compare the contents of ACC with number n.

JPE <address>

Following a compare instruction, jump to <address> if the compare was
True.

JPN <address>

Following a compare instruction, jump to <address> if the compare was
False.

AND #n

Bitwise AND operation of the contents of ACC with the operand.

AND <address>

Bitwise AND operation of the contents of ACC with the contents of
<address>.

XOR #n

Bitwise XOR operation of the contents of ACC with the operand.

XOR <address>
OR #n
OR <address>

Bitwise XOR operation of the contents of ACC with the contents of
<address>.
Bitwise OR operation of the contents of ACC with the operand.
Bitwise OR operation of the contents of ACC with the contents of
<address>.
<address> can be an absolute address or a symbolic address.

LSL #n

Bits in ACC are shifted n places to the left. Zeros are introduced on the
right hand end.

LSR #n

Bits in ACC are shifted n places to the right. Zeros are introduced on the
left hand end.

IN
OUT
END
© UCLES 2019

Key in a character and store its ASCII value in ACC.
Output to the screen the character whose ASCII value is stored in ACC.
Return control to the operating system.
9608/42/O/N/19

15

www.dynamicpapers.com

(a) A programmer needs a program that multiplies a binary number by 4.
The programmer has started to write the program in the following table. The comment column
contains explanations for the missing program instructions.
Write the program using the given instruction set.

Label

Instruction
Op code

Comment

Operand

// load contents of NUMBER
// perform shift to multiply by 4
// store contents of ACC in NUMBER
// end program
NUMBER:

B00110110
[5]

Note:
#
B
&

denotes immediate addressing
denotes a binary number, e.g. B01001010
denotes a hexadecimal number, e.g. &4A

© UCLES 2019

9608/42/O/N/19

[Turn over

16

www.dynamicpapers.com

(b) A programmer needs a program that counts the number of lower case letters in a string.
The programmer has started to write the program in the following table. The comment column
contains explanations for the missing program instructions.
Complete the program using the given instruction set. A copy of the instruction set is provided
on the opposite page.
Label

Instruction
Op code
LDR

Comment

Operand
#0

START:

// initialise Index Register to 0
// load the next value from the STRING
// perform bitwise AND operation with MASK
// check if result is equal to MASK
// if FALSE, jump to UPPER
// increment COUNT

UPPER:

INC

IX

// increment the Index Register
// decrement LENGTH
// is LENGTH = 0 ?
// if FALSE, jump to START

END
MASK:

B00100000

// end program
// if bit 5 is 1, letter is lower case

COUNT:

0

LENGTH:

5

STRING:

B01001000

// ASCII code for 'H'

B01100001

// ASCII code for 'a'

B01110000

// ASCII code for 'p'

B01110000

// ASCII code for 'p'

B01011001

// ASCII code for 'Y'
[8]

© UCLES 2019

9608/42/O/N/19

17
Instruction
Op code

Explanation

Operand

LDM #n

www.dynamicpapers.com

Immediate addressing. Load the number n to ACC.

LDD <address>

Direct addressing. Load the contents of the location at the given address to
ACC.

LDI <address>

Indirect addressing. The address to be used is at the given address. Load
the contents of this second address to ACC.

LDX <address>

Indexed addressing. Form the address from <address> + the contents of
the Index Register. Copy the contents of this calculated address to ACC.

LDR #n

Immediate addressing. Load the number n to IX.

STO <address>

Store the contents of ACC at the given address.

STX <address>

Indexed addressing. Form the address from <address> + the contents of
the Index Register. Copy the contents from ACC to this calculated address.

ADD <address>

Add the contents of the given address to the ACC.

INC <register>
DEC <register>
JMP <address>
CMP <address>
CMP #n

Add 1 to the contents of the register (ACC or IX).
Subtract 1 from the contents of the register (ACC or IX).
Jump to the given address.
Compare the contents of ACC with the contents of <address>.
Compare the contents of ACC with number n.

JPE <address>

Following a compare instruction, jump to <address> if the compare was
True.

JPN <address>

Following a compare instruction, jump to <address> if the compare was
False.

AND #n

Bitwise AND operation of the contents of ACC with the operand.

AND <address>

Bitwise AND operation of the contents of ACC with the contents of
<address>.

XOR #n

Bitwise XOR operation of the contents of ACC with the operand.

XOR <address>
OR #n
OR <address>

Bitwise XOR operation of the contents of ACC with the contents of
<address>.
Bitwise OR operation of the contents of ACC with the operand.
Bitwise OR operation of the contents of ACC with the contents of
<address>.
<address> can be an absolute address or a symbolic address.

LSL #n

Bits in ACC are shifted n places to the left. Zeros are introduced on the
right hand end.

LSR #n

Bits in ACC are shifted n places to the right. Zeros are introduced on the
left hand end.

IN
OUT
END

© UCLES 2019

Key in a character and store its ASCII value in ACC.
Output to the screen the character whose ASCII value is stored in ACC.
Return control to the operating system.

9608/42/O/N/19

18
BLANK PAGE

© UCLES 2019

9608/42/O/N/19

www.dynamicpapers.com

19
BLANK PAGE

© UCLES 2019

9608/42/O/N/19

www.dynamicpapers.com

20

www.dynamicpapers.com

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
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2019

9608/42/O/N/19

Advertisement