Algorithm design methods: decision tables, JSP and state-transition diagrams – A Level Computer Science (old syllabus, to 2021) (9608)

16 questions · page 1 of 2 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
9608/41/O/N/21 · Question 2Oct/Nov 2021Paper 414 marks
Loading question…
Question text

2
A grade generator program takes the mark a student obtained in a test as input.
The program calculates and outputs the grade that matches the mark. The grade is either A, B, C,
D or U.
Complete the following JSP structure diagram for the grade generator program.
GradeGenerator
[4]

2
9608/42/O/N/21 · Question 2Oct/Nov 2021Paper 424 marks
Loading question…
Question text

2
Complete the JSP structure diagram for the following pseudocode procedure.
PROCEDURE Calculate()
INPUT Number1
INPUT Number2
INPUT Command
IF Command = 1
THEN
Function1(Number1, Number2)
Value
ELSE
IF Command = 2
THEN
Function2(Number1, Number2)
Value
ELSE
Function3(Number1, Number2)
Value
ENDIF
ENDIF
OUTPUT Value
ENDPROCEDURE
JSP structure diagram
Calculate
[4]

3
9608/42/O/N/21 · Question 3Oct/Nov 2021Paper 423 marks
Loading question…
Question text

3
A user has to choose a new password to create an account. It is recommended that the password
has at least two of the following elements:
•
upper-case letter
•
numeric character
•
symbol.
The system outputs:
•
"Strong" if there are at least two of the elements
•
"Medium" if there is only one of the elements
•
"Weak" if there are none of the elements.
Complete the following decision table for the password system described.
Rules
One or more
upper-case
N
Y
N
Y
N
Y
N
Y
letters
One or more
Conditions
numeric
N
N
Y
Y
N
N
Y
Y
characters
One or more
N
N
N
N
Y
Y
Y
Y
symbols
Strong
Actions
Medium
Weak
[3]

Advertisement
4
9608/41/O/N/20 · Question 12Oct/Nov 2020Paper 418 marks
Loading question…
Question text

12 ENDFUNCTION
(a) State the line number in the pseudocode algorithm that shows function NumberPattern()
is recursive. Justify your choice.
Line number …
Justification …
…
…
[2]
(b) The function is called as follows:
NumberPattern(1,1,12)
Dry run the algorithm and complete the following trace table. State the final value returned.
Show your working.
Value1
Value2
Temp
EndValue
OUTPUT
RETURN value
Final value returned …
Working
…
…
…
…
…
…
…
[5]
(c) State the purpose of the algorithm.
…
… [1]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
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

5
9608/41/M/J/20 · Question 7May/June 2020Paper 4117 marks
Loading question…
Question text

7
(a) A shirt design company has an order form to order shirts. Customers can order multiple shirts
using the same form.
The customer details section has the data:
•
name
•
address
•
telephone number.
The order details section has the data:
•
shirt ID
•
colour
•
cost.
A total cost for the order is also calculated.
The cost of each shirt is dependent on the size ordered. The sizes customers can order are
small, medium and large.
Complete the following JSP data structure diagram for the order form.
Order Form
Customer Details
Total Cost
[7]
(b) Each customer’s order is stored as a record in a file. The customers’ orders are stored in the
order in which they arrive in the file and no key field is used.
(i)
Identify this type of file structure.
… [1]
(ii)
Identify two other types of file structure.
1 …
2 …
[2]
(c) The procedure UpdateTelephone() allows the shirt company to update the record for a
customer’s details. The procedure will update the telephone number.
The program stores customer details as a custom data type, Customer.
The definition for this data type is:
TYPE Customer
Name : STRING
Address : STRING
TelephoneNumber : STRING
ENDTYPE
The procedure UpdateTelephone() takes the customer record to be updated and the new
telephone number as parameters. It then updates the telephone number in the record.
Complete the pseudocode for the procedure UpdateTelephone().
PROCEDURE UpdateTelephone( … ThisCustomer : Customer,
… NewTelephoneNumber : STRING)
…
ENDPROCEDURE
[3]
(d) The shirt company is looking to implement a system to reward customers. The system
includes:
•
10% discount on orders over $50
•
free gift if order over $50 and if the order is placed on a Monday
•
additional 5% discount if a customer has a loyalty card
•
free delivery for a customer with a loyalty card and spends over $50.
Complete the following decision table for this system.
Order over $50
Y
Y
Y
Y
N
N
N
N
Conditions
Monday
Y
Y
N
N
Y
Y
N
N
Loyalty card
Y
N
Y
N
Y
N
Y
N
Additional 5% discount
10% discount
Actions
Free gift
Free delivery
[4]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
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

6
9608/42/M/J/20 · Question 4May/June 2020Paper 429 marks
Loading question…
Question text

4
(a) A tennis club has a booking form to book lessons with an instructor.
Club members can book up to five lessons using the booking form.
The customer details section has the data:
•
name
•
address
•
telephone number.
The lesson details section has the data:
•
lesson type
•
date and time
•
lesson cost.
The cost of each lesson is dependent on the customer’s type of membership. The membership
can be bronze, silver or gold.
The total cost is also calculated.
Complete the following JSP data structure diagram for the booking form.
Booking Form
Total Cost
Customer Details
[7]
(b) State two programming constructs that are shown in a JSP data structure diagram.
1 …
…
2 …
…
[2]

7
9608/42/O/N/19 · Question 4Oct/Nov 2019Paper 428 marks
Loading question…
Question text

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.
Insert card
Start
ATM
Waiting
active
for PIN
Enter PIN
Transaction
Transaction
Checking
complete
cancelled
PIN
Checking
Account
account
accessed
Input amount to withdraw
[8]

8
9608/42/O/N/18 · Question 1Oct/Nov 2018Paper 4210 marks
Loading question…
Question text

1
A bank provides bank accounts to customers.
The following pseudocode represents the operation of the bank account.
CALL OpenAccount()
CALL AccountLifeTime()
CALL CloseAccount()
PROCEDURE AccountLifeTime()
REPEAT
CALL Transactions()
UNTIL AccountClosed() = TRUE
ENDPROCEDURE
PROCEDURE CloseAccount()
IF ReopenAccount() = TRUE
THEN
CALL FlagToReopen()
ELSE
CALL DeletePermanently()
ENDIF
ENDPROCEDURE
(a) Complete the JSP structure diagram for this bank account from the pseudocode given.
Bank account
[6]
(b) A transaction can be a credit (deposit) or a debit (withdrawal).
There are two types of transaction that are credits (deposits). These are:
•
SWIFT payment
•
BACS payment
There are three types of transaction that are debits (withdrawals). These are:
•
Debit card payment
•
Cheque payment
•
Online payment
Complete the JSP structure diagram to represent these additional requirements.
Transaction
[4]

Advertisement
9
9608/41/M/J/18 · Question 3May/June 2018Paper 419 marks
Loading question…
Question text

3
An internet based music streaming service provides access to an unlimited number of songs for
members to play.
The following pseudocode represents the operation of the service.
CALL OpenAccount()
CALL OperateAccount()
CALL CloseAccount()
PROCEDURE OperateAccount()
WHILE RequestCloseAccount() = FALSE
IF SubscriptionDue() = TRUE
THEN
CALL MakePayment()
ELSE
CALL PlaySong()
ENDIF
ENDWHILE
ENDPROCEDURE
(a) Complete the JSP structure diagram for this music service from the pseudocode given.
Music Service
[5]
(b) The service needs extending so that members can download songs to play offline.
•
When a member selects a song, the service checks if the song has already been
downloaded.
•
If the member has already downloaded the song, the member has the option to delete or
play it.
•
If the member has not already downloaded the song they have the option to download or
stream it.
Complete the following JSP structure diagram to represent these new requirements.
Select Song
[4]

10
9608/42/M/J/18 · Question 1May/June 2018Paper 429 marks
Loading question…
Question text

1
Paul is using an application (app) called CAMplus. The app allows users to:
•
log in
•
create a new collection of photographs
•
use the camera to take new photographs
•
automatically add new photographs to the new collection
•
share the new collection with other users
•
start another collection or log out of the app.
The following JSP structure diagram represents the operation of CAMplus.
CAMplus
Create collections
Log out
Log in
*
Create a
collection
*
*
Add to collection
Add user
Add photo
Take photo
to collection
(a) An algorithm has been written in pseudocode to represent the Create collections operation
from the JSP structure diagram. The algorithm is incomplete.
Write pseudocode to complete this algorithm.
REPEAT
REPEAT
CALL TakePhoto
…
OUTPUT "Do you want to take another photo?"
INPUT AddPhoto
UNTIL AddPhoto = "No"
REPEAT
…
OUTPUT "Do you want to add another user?"
INPUT NewUser
UNTIL … = "No"
OUTPUT "Do you want to create another collection?"
…
UNTIL NewCollection = "No"
[4]
(b) The app is updated. Paul can now add and delete photos from chosen collections. Paul can
also delete collections.
Complete the JSP structure diagram to show the changes.
CAMplus
Manage
Log in
Log out
collections
*
Manage a
collection
O
Create a
collection
Add to *
*
Add user
collection
[5]
Question 2 begins on the next page.

11
9608/41/O/N/17 · Question 1Oct/Nov 2017Paper 417 marks
Loading question…
Question text

1
A greenhouse has a window that automatically opens and closes depending on the internal
temperature.
If the temperature rises above 20 °C, the window half opens. If the temperature rises above 30 °C,
the window fully opens. If the temperature drops below 25 °C, the window returns to being half
open. If the temperature drops below 15 °C, the window fully closes.
The window has three possible states: Closed, Half Open and Fully Open.
Current state
Event
Next state
Closed
Temperature rises above 20 °C
Half Open
Half Open
Temperature drops below 15 °C
Closed
Half Open
Temperature rises above 30 °C
Fully Open
Fully Open
Temperature drops below 25 °C
Half Open
Complete the state-transition diagram for the window:
…
…
…
…
…
…
…
…
…
…
…
…
…
…
[7]

12
9608/41/O/N/17 · Question 2Oct/Nov 2017Paper 417 marks
Loading question…
Question text

2
(a) (i)
State how repetition is shown in a Jackson Structured Programming (JSP) structure
diagram.
…
… [1]
(ii)
State how selection is shown in a JSP structure diagram.
…
… [1]
(b) A simple calculator is to be created.
The calculator is to be used as follows:
User inputs 2 numbers (x and y).
•
User inputs an operator (+, –, * or / ).
•
The calculator computes the answer.
•
The calculator displays the answer.
•
Draw a JSP diagram for the calculator. The first element is provided.
Calculator
[5]

13
9608/42/O/N/17 · Question 1Oct/Nov 2017Paper 4210 marks
Loading question…
Question text

1
Students are choosing their A Level subjects based on their IGCSE subject results.
A student can take:
•
Computer Science, if they have a grade C in Maths or a grade C in Computer Science
•
Maths, if they have a grade C in Maths
•
Physics, if they have a grade C in Science and a grade C in Maths.
(a) Complete the decision table.
Column
1
2
3
4
5
6
7
8
Grade C in
Y
Y
Y
Y
N
N
N
N
Conditions
Computer Science
Grade C in Maths
Y
Y
N
N
Y
Y
N
N
Grade C in Science
Y
N
Y
N
Y
N
Y
N
Take Computer
Science
Actions
Take Maths
Take Physics
[4]
(b) Simplify your solution by removing redundancies.
Column
S
T
U
V
W
X
Y
Z
Grade C in
Conditions
Computer Science
Grade C in Maths
Grade C in Science
Take Computer
Science
Actions
Take Maths
Take Physics
[3]
(c) Show how the columns from part (a) were simplified to create the columns in part (b).
For example, if columns 5, 6 and 7 were simplified to create column X, then you state this in
your answer.
…
…
…
…
…
… [3]

Advertisement
14
9608/42/O/N/16 · Question 1Oct/Nov 2016Paper 4239 marks
Loading question…
Question text

1
The ticket machine in the following diagram accepts the following coins: 10, 20, 50 and 100 cents.
The ticket machine has:
•
a slot to insert coins
•
a tray to return coins
•
a ticket dispenser
•
two buttons:
•
button A (Accept)
•
button C (Cancel)
$
Coin Slot
&
Coin
Ticket dispenser
return
tray
When the user has inserted as many coins as required, they press button A to print the ticket.
To cancel the transaction, the user can press button C. This makes the machine return the coins.
Invalid coins have no effect.
The following state transition table shows the transition from one state to another of the ticket
machine:
Current state
Event
Next state
Idle
Coin inserted
Counting
Counting
Coin inserted
Counting
Counting
Button C pressed
Cancelled
Cancelled
Coins returned
Idle
Counting
Button A pressed
Accepted
Accepted
Ticket printed
Idle
(a) Complete the state-transition diagram.
start
Coin inserted
…
…
…
Cancelled
Coins returned
…
…
…
…
[7]
(b) A company wants to simulate the use of a ticket machine. It will do this with object-oriented
programming (OOP).
The following diagram shows the design for the class TicketMachine. This includes its
attributes and methods.
TicketMachine
Amount : INTEGER // total value of coins inserted in cents
State : STRING // "Idle", "Counting", "Cancelled"
// or "Accepted"
Create()
//
method to create and initialise an object
//
if using Python use __init__
SetState()
//
set state to parameter value
//
and output new state
StateChange()
//
insert coin or press button,
//
then take appropriate action
CoinInserted()
//
parameter is a string
//
change parameter to integer
//
and add coin value to Amount
ReturnCoins()
//
output Amount, then set Amount to zero
PrintTicket()
//
print ticket, then set Amount to zero
Write program code for the following methods.
Programming language …
Create()
(i)
…
…
…
…
… [3]
SetState()
(ii)
…
…
…
… [2]
ReturnCoins()
(iii)
…
…
…
…

15
9608/41/M/J/16 · Question 3May/June 2016Paper 4112 marks
Loading question…
Question text

3
A car hire company hires cars to customers. Each time a car is hired, this is treated as a transaction.
For each transaction, the following data are stored.
For the customer:
•
customer name
•
ID number
For the hire:
•
car registration
•
hire start date
•
number of days hired
The transaction data are stored in a text file HIRE-TRANS. The file is made up of a file body,
F_BODY, and a file trailer, F_TRAILER.
F_BODY has one transaction, TRANS, on each line.
(a) The first step in Jackson Structured Programming (JSP) design is to produce a JSP data
structure diagram.
Complete the following JSP data structure diagram.
HIRE-TRANS
F_BODY
*
[7]
(b) The computer system will produce many printed reports.
One report is CAR_REPORT. This displays all hire data for all cars.
For each car, the following data are displayed:
•
the car data
•
a list of all the hires
•
the total number of hires
A car with zero hires is not included on the report.
Complete the following CAR_REPORT JSP data structure diagram.
CAR_REPORT
*
CAR
No hires
One or more hires
HIRE_LIST
HIRE
[5]

Advertisement