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

6 questions · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
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

2
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]

3
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]

Advertisement
4
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.

5
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]

6
9608/41/M/J/16 · Question 6May/June 2016Paper 4117 marks
Loading question…
Question text

6
In a board game, one player has white pieces and the other player has black pieces. Players take
alternate turns to move one of their pieces. White always makes the first move.
The game ends if:
•
a player is unable to make a move when it is their turn. In this case, there is no winner. This is
called ‘stalemate’.
•
a player wins the game as a result of their last move and is called a ‘winner’.
(a) A state-transition diagram is drawn to clarify how the game is played.
Complete the following state-transition diagram.
WHITE
WINS
No move
possible
:+,7(·6
TURN
Stalemate
BLACK moves
BLACK
%/$&.·6
WINS
TURN
Winning
move
[4]
(b) The layout of the board at the start of the game is shown below:
x
y
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
The programmer decides to use a 2D array to represent the board. The index numbering to
be used is as shown.
Each square on the board is either occupied by one piece only, or is empty.
The data stored in the array indicate whether or not that square is occupied, and if so, with a
black piece or a white piece.
(i)
Write program code to initialise the contents of the array to represent the board at the
start of the game. Use characters as follows for each square:
'B' represents a black piece
'W' represents a white piece
'E' represents an empty square
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.
Programming language …
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement