Computer Science (0478) · May/June 2020 · Question paper 23

Cambridge Computer Science (0478) question paper for paper 23, May/June 2020 — 0478/23/M/J/20, file 0478_s20_qp_23.pdf.

Advertisement
Loading the paper…
Text of this paper

www.dynamicpapers.com

Cambridge IGCSE™

* 0 6 3 3 5 0 5 5 3 3 *

COMPUTER SCIENCE

0478/23

Paper 2 Problem-solving and Programming

May/June 2020
1 hour 45 minutes

You must answer on the question paper.
No additional materials are needed.
INSTRUCTIONS
●
Answer all questions.
●
Do not attempt Tasks 1, 2 and 3 in the copy of the pre-release material on page 2; these are for
information only.
●
Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
●
Write your name, centre number and candidate number in the boxes at the top of the page.
●
Write your answer to each question in the space provided.
●
Do not use an erasable pen or correction fluid.
●
Do not write on any bar codes.
●
Calculators must not be used in this paper.
INFORMATION
●
The total mark for this paper is 50.
●
The number of marks for each question or part question is shown in brackets [ ].
●
No marks will be awarded for using brand names of software packages or hardware.

This document has 12 pages. Blank pages are indicated.
DC (CJ) 184934/3
© UCLES 2020

[Turn over

2

www.dynamicpapers.com

Section A
You are advised to spend no longer than 40 minutes answering this section.
Here is a copy of the pre-release material.
DO NOT attempt Tasks 1, 2 and 3 now.
Use the pre-release material and your experience from attempting the tasks before the examination to
answer Question 1.
Pre-release material
A school snack shop sells the following items:
Category
Fruit
Fruit
Fruit
Fruit
Sandwich
Sandwich
Sandwich
Sandwich
Sandwich
Crisps
Crisps
Crisps
Crisps
Confectionery
Confectionery
Confectionery
Confectionery
Drink
Drink
Drink
Drink
Drink

Item code
FR1
FR2
FR3
FR4
SN1
SN2
SN3
SN4
SN5
CR1
CR2
CR3
CR4
CN1
CN2
CN3
CN4
DR1
DR2
DR3
DR4
DR5

Description
Apple
Banana
Orange
Peach
Cheese
Cheese and Tomato
Chicken
Chicken Salad
Salad (Vegetarian)
Salted
Cheese and Onion
Barbecue
Prawn Cocktail
Biscuits
Chocolate Bar
Toffee and Chocolate Bar
Chocolate Wafers
Cola
Lemon and Lime Soda
Orange Soda
Orange Juice
Apple Juice

Price ($)
1.00
1.25
1.00
1.30
1.75
2.20
2.00
2.35
2.00
1.00
1.00
1.00
1.00
0.95
1.05
1.25
1.30
1.20
1.20
1.20
1.50
1.50

Healthy?
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes

Write and test a program or programs for this snack shop.
•
Your program or programs must include appropriate prompts for the entry of data; data must be
validated on entry.
•
Error messages and other output need to be set out clearly and understandably.
•
All arrays, variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
Task 1 – Setting up the system to show the items for sale and to allow items to be selected
Write a program to:
•
use arrays to store the item code, description, price and whether or not the item is healthy
•
allow a customer to choose an item to purchase
•
output the description of each chosen item, its price and whether or not it is healthy
•
allow the customer to choose additional items until they decide to stop
•
calculate and output the total price of the chosen items.
Task 2 – Specifying quantities and introducing restrictions
Extend Task 1 to:
•
allow the customer to input the quantity of each item they would like to purchase
•
count the number of healthy and unhealthy items chosen by the customer. For example, two
apples and a peach count as three healthy items
•
check that the customer has chosen at least one healthy item for every two unhealthy items.
If so, allow the customer to make the purchase. Otherwise, the purchase cannot proceed, a
message is output to say the purchase is cancelled and the customer has to start again.
Task 3 – Offering discounts
Extend the program to:
•
either apply a 10% discount to the total price, when purchasing both healthy and unhealthy
items, only if the number of healthy items matches or exceeds the number of unhealthy items
•
or apply a 20% discount to the total price if all the items purchased are healthy items
•
calculate then output the new total price and the amount of money saved.
© UCLES 2020

0478/23/M/J/20

3
1

www.dynamicpapers.com

All variables, constants and other identifiers must have meaningful names.
(a) (i)

Identify one array you could have used for Task 1 and state its purpose.
Array
Purpose

[2]

(ii)

Identify one variable you could have used for Task 2 and state its purpose.
Variable
Purpose

[2]

(iii)

Identify one constant you could have used for Task 3 and state its purpose.
Constant
Purpose

[2]

(b) Explain why a student would be advised not to store the Healthy? data as a real data type
and identify the most suitable data type for the Healthy? data.

[2]

© UCLES 2020

0478/23/M/J/20

[Turn over

4

www.dynamicpapers.com

(c) Write an algorithm for Task 1 using either pseudocode, programming statements or a
flowchart. It is not necessary to show initialisation or setting up of arrays.

© UCLES 2020

0478/23/M/J/20

5

www.dynamicpapers.com

[6]
© UCLES 2020

0478/23/M/J/20

[Turn over

6

www.dynamicpapers.com

(d) Explain how your program completes Task 3. Assume Task 1 and Task 2 have been
completed. Any programming statements used in your answer must be fully explained.

[4]
© UCLES 2020

0478/23/M/J/20

7

www.dynamicpapers.com

(e) Describe how you could alter your program to restrict the maximum number of items
purchased by a customer to six.

[2]

© UCLES 2020

0478/23/M/J/20

[Turn over

8

www.dynamicpapers.com

Section B
2

Draw a line to connect each Description to the most appropriate Pseudocode example.
Description

Pseudocode example

A loop that will iterate
at least once

CASE … OF … OTHERWISE … ENDCASE

A loop that will not be
executed on the first test
if the condition is false

Number

Number + 1

WHILE … DO … ENDWHILE

A conditional statement

Sum

Totalling

Sum + NewValue

REPEAT … UNTIL

Counting

[4]

© UCLES 2020

0478/23/M/J/20

9
3

www.dynamicpapers.com

This section of pseudocode is to be used as a validation check that will continue until a number
between 0 and 499 inclusive is entered.
1
2
3
4
5
6
7
8
9

PRINT "Input a number from 0 to 499 inclusive"
1 TO 10
FOR Number
INPUT Number
IF Number < 0 AND Number > 499
THEN
PRINT "Invalid number, please try again"
ENDIF
UNTIL Number = 0 OR Number = 499
PRINT Number, " is within the correct range"

There are three lines in this pseudocode that contain errors. In each case, state the line number
to identify the incorrect line and write out the corrected line in full.
Error 1 line number
Correction

Error 2 line number
Correction

Error 3 line number
Correction

[6]

© UCLES 2020

0478/23/M/J/20

[Turn over

10
4

www.dynamicpapers.com

A code must take the form LL9 9LL where L is a letter and 9 is a digit.
(a) A presence check has already been used to ensure data has been entered. Name two other
types of validation check that can be used to test the code is valid.
Check 1
Check 2
[2]
(b) Give one example of invalid test data for each of the validation checks you have named in
part (a) and in each case, give a reason why it fails the check. Each example of test data
must be different.
Check 1 Invalid Test Data

Reason

Check 2 Invalid Test Data

Reason

[4]

© UCLES 2020

0478/23/M/J/20

www.dynamicpapers.com

11
5

This algorithm finds prime numbers.
The pre-defined function DIV gives the value of the result of integer division,
9 DIV 4 gives y a value of 2
for example, y
False
Flag
INPUT Number
WHILE Number <> 0
2
Divisor
WHILE Divisor <= Number / 2
Number DIV Divisor
Value
IF Number / Divisor = Value
THEN
True
Flag
ENDIF
Divisor + 1
Divisor
ENDWHILE
IF Flag = False
THEN
OUTPUT Number, " is prime"
ENDIF
INPUT Number
False
Flag
ENDWHILE
Complete the trace table for the algorithm using the input data:
5, 6, 8, 0, 11, 13
Flag

Number Divisor Value

OUTPUT

[5]

© UCLES 2020

0478/23/M/J/20

[Turn over

www.dynamicpapers.com

12
6

Draw the flowchart symbol for Decision and the flowchart symbol for Process.
Decision

Process

[2]
7

A convenience store which sells general groceries wants to set up a database table called
STOCK. The table will contain fields including a description of the item, the price of the item
and the number in stock for each item. The STOCK table also has a fourth field to be used as a
primary key.
(a) Complete the table to suggest a suitable field name for each of the four fields in the table
STOCK. Give the purpose of the data to be stored in each field.
Field name

Purpose of field contents

[4]
(b) Complete the query-by-example grid to output stock items where the quantity in stock has
fallen below 20. Only show the primary key and description of the items.
Field:
Table:
Sort:
Show:
Criteria:
or:
[3]
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 2020

0478/23/M/J/20

Advertisement