0% found this document useful (0 votes)
33 views

2015 ALL P2_merged

This document is an examination paper for the Cambridge International General Certificate of Secondary Education in Computer Science. It includes instructions for candidates, a series of programming tasks related to data logging and validation, and questions on algorithms, data types, and database queries. The examination consists of two sections with a total of 50 marks available.

Uploaded by

nainikmakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

2015 ALL P2_merged

This document is an examination paper for the Cambridge International General Certificate of Secondary Education in Computer Science. It includes instructions for candidates, a series of programming tasks related to data logging and validation, and questions on algorithms, data types, and database queries. The examination consists of two sections with a total of 50 marks available.

Uploaded by

nainikmakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 928

Cambridge International Examinations

Cambridge International General Certificate of Secondary Education


* 1 2 2 8 8 3 3 8 1 5 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (CW/CGW) 95070/2
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

TASK 1

A data logger records the temperature on the roof of a school twice a day, at midday and midnight.
Input and store the temperatures recorded for a month. You must store the temperatures in two one-
dimensional arrays, one for the midday temperatures and one for the midnight temperatures. All the
temperatures must be validated on entry and any invalid temperatures rejected. You must decide
your own validation rules. You may assume that there are 30 days in a month.

TASK 2

Calculate the average temperature for midday and the average temperature for midnight. Output
these averages with a suitable message for each one.

TASK 3

Select the day with the highest midday temperature and the day with the lowest midnight temperature.
Then output each of these temperatures, the corresponding day and a suitable message.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/21/M/J/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) In Task 1, you had to store the midday temperatures and midnight temperatures in
arrays.

Write suitable declarations for these two arrays.

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) It has been decided to record the temperatures for one week rather than one month.

Write the new array declarations that you would use.

...........................................................................................................................................

.......................................................................................................................................[1]

(iii) Declare two other variables that you have used and state what you used each one for.

Variable 1 ...........................................................................................................................

Use .....................................................................................................................................

Variable 2 ...........................................................................................................................

Use .................................................................................................................................[4]

© UCLES 2015 0478/21/M/J/15 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. Use temperatures for one week only. You should assume that Task 1 has
already been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/21/M/J/15


5

(c) Give a set of midday temperature data, for a week, that could be used to check your validation
rules for Task 1. Explain why you chose this data set.

Data set .....................................................................................................................................

...................................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(d) Explain how you select the day with the highest midday temperature (part of Task 3). You may
include pseudocode or programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]
© UCLES 2015 0478/21/M/J/15 [Turn over
6

Section B

2 Read this section of program code that should input 10 positive numbers and then output the
smallest number input.

1 Small = 0

2 Counter = 0

3 REPEAT

4 INPUT Num

5 IF Num < Small THEN Num = Small

6 Counter = Counter + 1

7 PRINT Small

8 UNTIL Counter < 10

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/21/M/J/15


7

Question 3 begins on page 8.

© UCLES 2015 0478/21/M/J/15 [Turn over


8

3 The flowchart below inputs the weight of a number of parcels in kilograms. Parcels weighing more
than 25 kilograms are rejected. A value of –1 stops the input.

The following information is output: the total weight of the parcels accepted and number of parcels
rejected.

START

7RWDOĸ
5HMHFWĸ

INPUT
Weight

Is Weight Yes OUTPUT Total,


= –1? Reject

No END

Is Weight Yes
5HMHFWĸ5HMHFW
> 25?

No

7RWDOĸ7RWDO:HLJKW

© UCLES 2015 0478/21/M/J/15


9

Complete the trace table for the input data:

1.8, 26.0, 7.0, 11.3, 10.0, 2.5, 25.2, 5.0, 19.8, 29.3, –1

Total Reject Weight OUTPUT

[5]

4 Five data types and five data samples are shown below.

Draw a line to link each data type to the correct data sample.

Data type Data sample


Integer 'a'

Real 2

Char 2.0

String True

Boolean "Twelve"
[4]

© UCLES 2015 0478/21/M/J/15 [Turn over


10

5 Explain the difference between a variable and a constant in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[2]

6 Identify three different loop structures that you can use when writing pseudocode.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

......................................................................................................................................................[3]

7 A database, PROPERTY, was set up to show the prices of properties for sale and the features of
each property. Part of the database is shown below.

Brochure Number of Number of Price


Property Type Garden Garage
No Bedrooms Bathrooms in $
Bungalow B17 7 4 Yes Yes 750,000
Apartment A09 2 1 No No 100,000
House H10 4 2 Yes No 450,000
House H13 3 2 Yes No 399,000
Apartment A01 2 2 No Yes 95,000
Apartment A16 1 1 No No 150,000
House H23 3 1 No Yes 250,000
House H46 2 1 Yes Yes 175,000

(a) Give the number of fields that are in each record.

...............................................................................................................................................[1]

© UCLES 2015 0478/21/M/J/15


11

(b) State which field you would choose for the primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) State the data type you would choose for each of the following fields.

Garage .....................................................................................................................................

Number of Bedrooms .............................................................................................................

Price in $ ..............................................................................................................................[3]

(d) The query-by-example grid below selects all houses with more than 1 bathroom and more
than 2 bedrooms.

Number of Number of
Field: Property Type Price in $ Brochure No
Bedrooms Bathrooms
Table: PROPERTY PROPERTY PROPERTY PROPERTY PROPERTY
Sort: Ascending
Show:  
Criteria: = 'House' >2 >1
or:

Show what would be output.

...................................................................................................................................................

...............................................................................................................................................[2]

(e) Complete the query-by-example grid below to select and show the brochure number, property
type and price of all properties with a garage below $200,000.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2015 0478/21/M/J/15


12

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.

© UCLES 2015 0478/21/M/J/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 6 6 5 1 9 7 7 5 5 0 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (CW/CGW) 95074/2
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

TASK 1

A school keeps records of the weights of each pupil. The weight, in kilograms, of each pupil is
recorded on the first day of term. Input and store the weights and names recorded for a class of
30 pupils. You must store the weights in a one-dimensional array and the names in another one-
dimensional array. All the weights must be validated on entry and any invalid weights rejected. You
must decide your own validation rules. You may assume that the pupils’ names are unique. Output
the names and weights of the pupils in the class.

TASK 2

The weight, in kilograms, of each pupil is recorded again on the last day of term. Calculate and store
the difference in weight for each pupil.

TASK 3

For those pupils who have a difference in weight of more than 2.5 kilograms, output, with a suitable
message, the pupil’s name, the difference in weight and whether this is a rise or a fall.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/22/M/J/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare the array to store the pupils’ names.

.......................................................................................................................................[1]

(ii) Declare the array to store the pupils’ weights.

.......................................................................................................................................[1]

(iii) It has been decided to record the weights for the whole school of 600 pupils rather than
one class.

Write suitable new declarations for these two arrays.

...........................................................................................................................................

.......................................................................................................................................[1]

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. Use weights for the whole school. You should assume that Task 1 has already
been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/22/M/J/15 [Turn over


4

(c) (i) Describe suitable validation rules for Task 1.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Give two pupil weights that you could use to check the validation used in Task 1. Explain
why you chose each weight.

Weight 1 ............................................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

Weight 2 ............................................................................................................................

Reason for choice .............................................................................................................

.......................................................................................................................................[4]

(d) Explain how you select the pupils with a fall in weight of more than 2.5 kilograms (part of
Task 3). You may include pseudocode or programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

© UCLES 2015 0478/22/M/J/15


5

Section B

2 Read this section of program code that should input 30 positive numbers and then output the
largest number input.

1 Large = 9999

2 Counter = 0

3 WHILE Counter > 30

4 DO

5 INPUT Num

6 IF Num < Large THEN Large = Num

7 Counter = Counter - 1

8 ENDWHILE

9 PRINT Large

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/22/M/J/15 [Turn over


6

3 (a) The flowchart below inputs six single digit numbers. The predefined function MOD gives the
value of the remainder, for example, Y ← 10 MOD 3 gives the value Y = 1

START

INPUT
A, B, C, D, E, F

Total @ A*1 + B*2 + C*3 + D*4 + E*5

Check @ Total MOD 11

Is Check = Yes OUTPUT


F? 'Accept'

No

OUTPUT
'Reject'

END

© UCLES 2015 0478/22/M/J/15


7

Complete a trace table for each of the two sets of input data.

Set 1 5, 2, 4, 3, 1, 5

Set 2 3, 2, 1, 0, 7, 3

Trace table set 1 5, 2, 4, 3, 1, 5

A B C D E F Total Check Output

Trace table set 2 3, 2, 1, 0, 7, 3

A B C D E F Total Check Output

[4]

(b) State the purpose of the flowchart in part (a).

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Identify a problem with this flowchart and explain how to correct it.

Problem ....................................................................................................................................

...................................................................................................................................................

Solution .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2015 0478/22/M/J/15 [Turn over


8

4 Four programming concepts and four examples of programming code are shown below.

Draw a line to link each programming concept to the correct example of programming code.

Programming
Example of programming code
concept

Counting Sum = Sum + Value[n]

Repetition IF Value = 10 THEN PRINT 'X'

Selection FOR Counter = 1 TO 10

Totalling Amount = Amount + 1

Sum = Num1 + Num2


[4]

5 (a) Write an algorithm, using pseudocode and a FOR … TO … NEXT loop structure, to input
1000 numbers into an array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Rewrite your algorithm using another loop structure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2015 0478/22/M/J/15


9

Question 6 begins on page 10.

© UCLES 2015 0478/22/M/J/15 [Turn over


10

6 A database, MARKS, was set up to record the test results for a class of students. Part of the
database is shown below.

Student Name Class ID Maths English Science History Geography


Paul Smith 0017 70 55 65 62 59
Ravi Gupta 0009 29 34 38 41 44
Chin Hwee 0010 43 47 50 45 52
John Jones 0013 37 67 21 28 35
Diana Abur 0001 92 88 95 89 78
Rosanna King 0016 21 13 11 27 15

(a) Give the number of fields that are in each record.

...............................................................................................................................................[1]

(b) State which field you would choose for the primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) The query-by-example grid below selects all students with more than 60 marks in History or
more than 60 marks in Geography.

Field: Student Name History Geography

Table: MARKS MARKS MARKS

Sort: Ascending

Show: ✓
Criteria: >60

or: >60

Show what would be output.

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2015 0478/22/M/J/15


11

(d) Complete the query-by-example grid below to select and show the student names only of all
students with less than 40 marks in both Maths and English.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2015 0478/22/M/J/15


12

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.

© UCLES 2015 0478/22/M/J/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 0 8 1 6 1 9 4 2 5 7 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (SLM) 108498
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

TASK 1

A data logger records the temperature on the roof of a school twice a day, at midday and midnight.
Input and store the temperatures recorded for a month. You must store the temperatures in two one-
dimensional arrays, one for the midday temperatures and one for the midnight temperatures. All the
temperatures must be validated on entry and any invalid temperatures rejected. You must decide
your own validation rules. You may assume that there are 30 days in a month.

TASK 2

Calculate the average temperature for midday and the average temperature for midnight. Output
these averages with a suitable message for each one.

TASK 3

Select the day with the highest midday temperature and the day with the lowest midnight temperature.
Then output each of these temperatures, the corresponding day and a suitable message.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/23/M/J/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) In Task 1, you had to store the midday temperatures and midnight temperatures in
arrays.

Write suitable declarations for these two arrays.

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) It has been decided to record the temperatures for one week rather than one month.

Write the new array declarations that you would use.

...........................................................................................................................................

.......................................................................................................................................[1]

(iii) Declare two other variables that you have used and state what you used each one for.

Variable 1 ...........................................................................................................................

Use .....................................................................................................................................

Variable 2 ...........................................................................................................................

Use .................................................................................................................................[4]

© UCLES 2015 0478/23/M/J/15 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. Use temperatures for one week only. You should assume that Task 1 has
already been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/23/M/J/15


5

(c) Give a set of midday temperature data, for a week, that could be used to check your validation
rules for Task 1. Explain why you chose this data set.

Data set .....................................................................................................................................

...................................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(d) Explain how you select the day with the highest midday temperature (part of Task 3). You may
include pseudocode or programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]
© UCLES 2015 0478/23/M/J/15 [Turn over
6

Section B

2 Read this section of program code that should input 10 positive numbers and then output the
smallest number input.

1 Small = 0

2 Counter = 0

3 REPEAT

4 INPUT Num

5 IF Num < Small THEN Num = Small

6 Counter = Counter + 1

7 PRINT Small

8 UNTIL Counter < 10

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/23/M/J/15


7

Question 3 begins on page 8.

© UCLES 2015 0478/23/M/J/15 [Turn over


8

3 The flowchart below inputs the weight of a number of parcels in kilograms. Parcels weighing more
than 25 kilograms are rejected. A value of –1 stops the input.

The following information is output: the total weight of the parcels accepted and number of parcels
rejected.

START

7RWDOĸ
5HMHFWĸ

INPUT
Weight

Is Weight Yes OUTPUT Total,


= –1? Reject

No END

Is Weight Yes
5HMHFWĸ5HMHFW
> 25?

No

7RWDOĸ7RWDO:HLJKW

© UCLES 2015 0478/23/M/J/15


9

Complete the trace table for the input data:

1.8, 26.0, 7.0, 11.3, 10.0, 2.5, 25.2, 5.0, 19.8, 29.3, –1

Total Reject Weight OUTPUT

[5]

4 Five data types and five data samples are shown below.

Draw a line to link each data type to the correct data sample.

Data type Data sample


Integer 'a'

Real 2

Char 2.0

String True

Boolean "Twelve"
[4]

© UCLES 2015 0478/23/M/J/15 [Turn over


10

5 Explain the difference between a variable and a constant in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[2]

6 Identify three different loop structures that you can use when writing pseudocode.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

......................................................................................................................................................[3]

7 A database, PROPERTY, was set up to show the prices of properties for sale and the features of
each property. Part of the database is shown below.

Brochure Number of Number of Price


Property Type Garden Garage
No Bedrooms Bathrooms in $
Bungalow B17 7 4 Yes Yes 750,000
Apartment A09 2 1 No No 100,000
House H10 4 2 Yes No 450,000
House H13 3 2 Yes No 399,000
Apartment A01 2 2 No Yes 95,000
Apartment A16 1 1 No No 150,000
House H23 3 1 No Yes 250,000
House H46 2 1 Yes Yes 175,000

(a) Give the number of fields that are in each record.

...............................................................................................................................................[1]

© UCLES 2015 0478/23/M/J/15


11

(b) State which field you would choose for the primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) State the data type you would choose for each of the following fields.

Garage .....................................................................................................................................

Number of Bedrooms .............................................................................................................

Price in $ ..............................................................................................................................[3]

(d) The query-by-example grid below selects all houses with more than 1 bathroom and more
than 2 bedrooms.

Number of Number of
Field: Property Type Price in $ Brochure No
Bedrooms Bathrooms
Table: PROPERTY PROPERTY PROPERTY PROPERTY PROPERTY
Sort: Ascending
Show:  
Criteria: = 'House' >2 >1
or:

Show what would be output.

...................................................................................................................................................

...............................................................................................................................................[2]

(e) Complete the query-by-example grid below to select and show the brochure number, property
type and price of all properties with a garage below $200,000.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2015 0478/23/M/J/15


12

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.

© UCLES 2015 0478/23/M/J/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 6 8 7 3 5 2 6 4 2 6 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (CW/CGW) 95072/2
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

A new born baby is kept in a cot in a hospital; the temperature of the baby is monitored every
10 minutes. The temperature of the baby is recorded in degrees Celsius to one decimal place and
must be within the range 36.0°C to 37.5°C.

TASK 1

To simulate the monitoring required, write a routine that allows entry of the baby’s temperature in
degrees Celsius. The routine should check whether the temperature is within the acceptable range,
too high or too low and output a suitable message in each case.

TASK 2

Write another routine that stores the temperatures taken over a three hour period in an array. This
routine should output the highest and lowest temperatures and calculate the difference between
these temperatures.

TASK 3

For a baby who has a temperature difference of more than one degree Celsius, and/or has been
outside the acceptable range more than twice in the three hour period, output a suitable message
giving a summary of the problem.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/21/O/N/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) When you performed the tasks, you used variables.

Write suitable declarations for two of these.


State what you used each one for.

Variable 1 ..........................................................................................................................

Use ....................................................................................................................................

Variable 2 ..........................................................................................................................

Use ................................................................................................................................[4]

(ii) When you performed the tasks, you may have used constants.

Write suitable declarations for two of these.


State what you used each one for.

Constant 1 .........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Constant 2 .........................................................................................................................

Use ....................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2015 0478/21/O/N/15 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/21/O/N/15


5

(c) (i) Explain how you completed Task 3. You can include pseudocode or programming
statements as part of your explanation. You should assume that Task 2 has been
completed.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

(ii) Comment on the efficiency of your design for Task 3.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 0478/21/O/N/15 [Turn over


6

Section B

2 Read this section of program code that should input 50 numbers and then output the average.

1 Total = 0

2 For Counter = 1 TO 50

3 INPUT Num

4 Total = Total + 1

5 Counter = Counter + 1

6 Average = Total/Counter

7 NEXT Counter

8 PRINT Average

There are four errors in this code.

Locate these errors and suggest code corrections to remove each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/21/O/N/15


7

Question 3 begins on page 8.

© UCLES 2015 0478/21/O/N/15 [Turn over


8

3 (a) The flowchart inputs an integer. The predefined function DIV gives the integer result of the
division, e.g. Y 10 DIV 3 gives the value Y = 3. The predefined function MOD gives the
value of the remainder, e.g. Y 10 MOD 3 gives the value Y = 1.

START

Posn @ 1
New @ 0

INPUT X

T1 @ X DIV 2
T2 @ X MOD 2
New @New+T2 * Posn
Posn @Posn * 10

X @T1

Yes is T1
>= 2?

No

New @New+T1 * Posn

OUTPUT New

END

© UCLES 2015 0478/21/O/N/15


9

Complete a trace table for each of the two input values 5 and 12.

Trace table for input value 5

X Posn New T1 T2 OUTPUT

Trace table for input value 12

X Posn New T1 T2 OUTPUT

[6]

(b) State the purpose of the flowchart in part (a).

...............................................................................................................................................[1]

© UCLES 2015 0478/21/O/N/15 [Turn over


10

4 A routine checks the weight of melons to be sold in a supermarket. Melons weighing under
0.5 kilograms are rejected and melons weighing over 2 kilograms are also rejected.

Give an example of each type of test data for this routine.

Normal .............................................................................................................................................

Extreme ............................................................................................................................................

Abnormal ......................................................................................................................................[3]

5 Identify two different conditional statements that you can use when writing pseudocode.

1 .......................................................................................................................................................

2 ...................................................................................................................................................[2]

6 A picture gallery owner has decided to set up a database to keep information about the pictures
he has for sale. The database table, PICTURE, will contain the following fields:

Title; Artist; Description; Catalogue Number; Size (area in square centimetres); Price; Arrived (date
picture arrived at gallery); Sold (whether picture is already sold)

(a) (i) State what data type you would choose for each field.

Title ...................................................................................................................................

Artist ..................................................................................................................................

Description ........................................................................................................................

Catalogue Number ............................................................................................................

Size ...................................................................................................................................

Price ..................................................................................................................................

Arrived ...............................................................................................................................

Sold ...............................................................................................................................[4]

(ii) State which field you would choose for the primary key.

.......................................................................................................................................[1]

© UCLES 2015 0478/21/O/N/15


11

(b) Give a validation check that you can perform on each of these fields. Each validation check
must be different.

Catalogue Number ....................................................................................................................

Size ...........................................................................................................................................

Price .........................................................................................................................................

Arrived ..................................................................................................................................[4]

(c) Complete the query-by-example grid below to select and show the Catalogue Number, Title
and Price of all unsold pictures by the artist ‘Twister’.

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2015 0478/21/O/N/15


12

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.

© UCLES 2015 0478/21/O/N/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 7 1 7 7 1 4 9 2 5 4 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (ST/CGW) 113107
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

A new born baby is kept in a cot in a hospital; the temperature of the baby is monitored every
10 minutes. The temperature of the baby is recorded in degrees Celsius to one decimal place and
must be within the range 36.0°C to 37.5°C.

TASK 1

To simulate the monitoring required, write a routine that allows entry of the baby’s temperature in
degrees Celsius. The routine should check whether the temperature is within the acceptable range,
too high or too low and output a suitable message in each case.

TASK 2

Write another routine that stores the temperatures taken over a three hour period in an array. This
routine should output the highest and lowest temperatures and calculate the difference between
these temperatures.

TASK 3

For a baby who has a temperature difference of more than one degree Celsius, and/or has been
outside the acceptable range more than twice in the three hour period, output a suitable message
giving a summary of the problem.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/22/O/N/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) When you performed the tasks, you used variables.

Write suitable declarations for two of these.


State what you used each one for.

Variable 1 ..........................................................................................................................

Use ....................................................................................................................................

Variable 2 ..........................................................................................................................

Use ................................................................................................................................[4]

(ii) When you performed the tasks, you may have used constants.

Write suitable declarations for two of these.


State what you used each one for.

Constant 1 .........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Constant 2 .........................................................................................................................

Use ....................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2015 0478/22/O/N/15 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/22/O/N/15


5

(c) (i) Explain how you completed Task 3. You can include pseudocode or programming
statements as part of your explanation. You should assume that Task 2 has been
completed.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

(ii) Comment on the efficiency of your design for Task 3.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2015 0478/22/O/N/15 [Turn over


6

Section B

2 Read this section of program code that should input 50 numbers and then output the average.

1 Total = 0

2 For Counter = 1 TO 50

3 INPUT Num

4 Total = Total + 1

5 Counter = Counter + 1

6 Average = Total/Counter

7 NEXT Counter

8 PRINT Average

There are four errors in this code.

Locate these errors and suggest code corrections to remove each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/22/O/N/15


7

Question 3 begins on page 8.

© UCLES 2015 0478/22/O/N/15 [Turn over


8

3 (a) The flowchart inputs an integer. The predefined function DIV gives the integer result of the
division, e.g. Y 10 DIV 3 gives the value Y = 3. The predefined function MOD gives the
value of the remainder, e.g. Y 10 MOD 3 gives the value Y = 1.

START

Posn @ 1
New @ 0

INPUT X

T1 @ X DIV 2
T2 @ X MOD 2
New @New+T2 * Posn
Posn @Posn * 10

X @T1

Yes is T1
>= 2?

No

New @New+T1 * Posn

OUTPUT New

END

© UCLES 2015 0478/22/O/N/15


9

Complete a trace table for each of the two input values 5 and 12.

Trace table for input value 5

X Posn New T1 T2 OUTPUT

Trace table for input value 12

X Posn New T1 T2 OUTPUT

[6]

(b) State the purpose of the flowchart in part (a).

...............................................................................................................................................[1]

© UCLES 2015 0478/22/O/N/15 [Turn over


10

4 A routine checks the weight of melons to be sold in a supermarket. Melons weighing under
0.5 kilograms are rejected and melons weighing over 2 kilograms are also rejected.

Give an example of each type of test data for this routine.

Normal .............................................................................................................................................

Extreme ............................................................................................................................................

Abnormal ......................................................................................................................................[3]

5 Identify two different conditional statements that you can use when writing pseudocode.

1 .......................................................................................................................................................

2 ...................................................................................................................................................[2]

6 A picture gallery owner has decided to set up a database to keep information about the pictures
he has for sale. The database table, PICTURE, will contain the following fields:

Title; Artist; Description; Catalogue Number; Size (area in square centimetres); Price; Arrived (date
picture arrived at gallery); Sold (whether picture is already sold)

(a) (i) State what data type you would choose for each field.

Title ...................................................................................................................................

Artist ..................................................................................................................................

Description ........................................................................................................................

Catalogue Number ............................................................................................................

Size ...................................................................................................................................

Price ..................................................................................................................................

Arrived ...............................................................................................................................

Sold ...............................................................................................................................[4]

(ii) State which field you would choose for the primary key.

.......................................................................................................................................[1]

© UCLES 2015 0478/22/O/N/15


11

(b) Give a validation check that you can perform on each of these fields. Each validation check
must be different.

Catalogue Number ....................................................................................................................

Size ...........................................................................................................................................

Price .........................................................................................................................................

Arrived ..................................................................................................................................[4]

(c) Complete the query-by-example grid below to select and show the Catalogue Number, Title
and Price of all unsold pictures by the artist ‘Twister’.

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2015 0478/22/O/N/15


12

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.

© UCLES 2015 0478/22/O/N/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 3 8 3 8 7 9 6 9 9 2 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2015
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 11 printed pages and 1 blank page.

DC (CW) 95077/3
© UCLES 2015 [Turn over
2

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

Write and test a program to complete the three tasks.

The temperature in an apartment needs to be kept between 22°C and 24°C. This is done by the use
of an automatically controlled air-conditioning system, which monitors the temperature every five
minutes. The temperature of the apartment is recorded, to one decimal place, in degrees Celsius.
The cooling is activated when the temperature reaches 24.5°C and the heating is activated when the
temperature reaches 21.5°C.

TASK 1

To simulate the monitoring required, write a routine that allows entry of the apartment’s temperature
in degrees Celsius. The routine checks whether the temperature is within the acceptable range, too
high or too low and outputs a suitable message in each case.

TASK 2

Write another routine that stores, in an array, the temperatures taken over a period of five hours.
This routine calculates the difference between the highest temperature and the lowest temperature.
Then it outputs the highest temperature, the lowest temperature, and the difference between these
temperatures.

TASK 3

Write a routine to find out how often the temperature was out of the acceptable range during the five
hours and whether the temperature was too high or too low; output a suitable message showing a
summary of the problem.

Your program must include appropriate prompts for the entry of data. Error messages and other
outputs need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2015 0478/23/O/N/15


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) When you performed the tasks, you used variables.

Write suitable declarations for two of these.


State what you used each one for.

Variable 1 ..........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Variable 2 ..........................................................................................................................

Use ....................................................................................................................................

.......................................................................................................................................[4]

(ii) When you performed the tasks, you may have used constants.

Write suitable declarations for two of these.


State what you used each one for.

Constant 1 .........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Constant 2 .........................................................................................................................

Use ....................................................................................................................................

.......................................................................................................................................[4]

© UCLES 2015 0478/23/O/N/15 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You should assume that the temperatures taken over the five hours are already
stored in an array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2015 0478/23/O/N/15


5

(c) (i) Explain how you completed Task 3. You should assume that Task 2 has been completed.
You can include pseudocode or programming statements as part of your explanation.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[6]

(ii) Comment on the efficiency of your design for Task 3.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2015 0478/23/O/N/15 [Turn over


6

Section B

2 Read this section of program code that should input 50 numbers and then output the average of
the positive numbers only.

1 Total = 0

2 PosCount = 0

3 FOR Counter = 1 TO 50

4 INPUT Num

5 IF Num < 0 THEN Total = Total + Num

6 IF Num > 0 THEN Counter = Counter + 1

7 Average = Total/PosCount

8 NEXT Counter

9 PRINT Num

There are four errors in this code.

Locate these errors and suggest code corrections to remove each error.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................

4 .......................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2015 0478/23/O/N/15


7

Question 3 begins on page 8.

© UCLES 2015 0478/23/O/N/15 [Turn over


8

3 (a) This pseudocode inputs an integer. The predefined function DIV gives the value of the
division, e.g. Y 10 DIV 3 gives the value Y = 3. The predefined function MOD gives the
value of the remainder, e.g. Y 10 MOD 3 gives the value Y = 1.

INPUT X
WHILE X > 15
DO
T1 X DIV 16
T2 X MOD 16
CASE T2 OF
10:OUTPUT A
11:OUTPUT B
12:OUTPUT C
13:OUTPUT D
14:OUTPUT E
15:OUTPUT F
OTHERWISE OUTPUT T2
ENDCASE
X T1
ENDWHILE
CASE X OF
10:OUTPUT A
11:OUTPUT B
12:OUTPUT C
13:OUTPUT D
14:OUTPUT E
15:OUTPUT F
OTHERWISE OUTPUT X
ENDCASE

© UCLES 2015 0478/23/O/N/15


9

Complete a trace table for each of the two input values 37 and 191.

Trace table for input value 37

X T1 T2 OUTPUT

Trace table for input value 191

X T1 T2 OUTPUT

[4]

(b) State the purpose of the pseudocode in part (a).

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2015 0478/23/O/N/15 [Turn over


10

4 A routine checks the age and height of children who are allowed to enter a play area. The children
must be less than 5 years of age and under 1 metre in height.

(a) The first set of test data used is age 3 and height 0.82 metres.

State what type of test data this is.

...................................................................................................................................................

Give a reason for using this test data.

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Provide two additional sets of test data. For each, give

• the type of each set of test data


• the reason why it is used

Each type of test data and reason for use must be different.

Set 1 .........................................................................................................................................

Type ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Type ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

© UCLES 2015 0478/23/O/N/15


11

5 A motor boat hire company decides to set up a database to keep information about boats that are
available for hire. The database table, BOAT, will contain the following fields:

Boat Name; Model; Engine Power (in hp); Number of Seats; Life Raft (whether there is a life raft
kept on the boat); Day Price (price for a day’s hire).

(a) Give the data type you would choose for each field.

Boat Name ................................................................................................................................

Model ........................................................................................................................................

Engine Power ............................................................................................................................

Number of Seats .......................................................................................................................

Life Raft ....................................................................................................................................

Day Price ..............................................................................................................................[3]

(b) State a validation check that you can perform on each of these fields. Each validation check
must be different.

Boat Name ................................................................................................................................

Model ........................................................................................................................................

Number of Seats .......................................................................................................................

Day Price ..............................................................................................................................[4]

(c) Complete the query-by-example grid below to select and show the Boat Name, Model and
Day Price of a day’s hire for all boats with 4 seats and an Engine Power of more than 100 hp.

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2015 0478/23/O/N/15


12

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.

© UCLES 2015 0478/23/O/N/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education

COMPUTER SCIENCE 0478/02


Paper 2 Problem-solving and Programming For Examination from 2015
SPECIMEN PAPER
1 hour 45 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.

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.
Calculators must not be used in this paper.

Answer all questions.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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.

This document consists of 13 printed pages and 3 blank pages.

© UCLES 2012 [Turn over


2

BLANK PAGE

© UCLES 2012 0478/02/SP/15


3

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 Section A Question 1.

Pre-release material

Write and test a program to complete the three tasks.

TASK 1

Input and store the names and marks for 30 students who have sat three computer science tests.
Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the
names in a one-dimensional array and the marks and total score for each student in one-dimensional
arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume
that the students’ names are unique.

TASK 2

Calculate and store the total score for each student and calculate the average score for the whole
class. Output each student’s name followed by their total score, then output the average score for the
class.

TASK 3

Select the student with the highest score and output their name and score.

Your program must include appropriate prompts for the entry of data. Error messages and other
output need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2012 0478/02/SP/15 [Turn over


4

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare the array to store the students’ names.

[1]

(ii) Declare the arrays to store each student’s marks and total score.

[2]

(b) (i) Show the design of your algorithm to complete Task 1 and Task 2 using pseudocode,
programming statements or a flowchart. Do not include any of the validation checks in
your algorithm.

[8]

© UCLES 2012 0478/02/SP/15


5

(ii) Comment on the efficiency of your design.

[1]

(c) Show two different sets of student data that you could use to check the validation used in
Task 1. Explain why you chose each data set.

Set 1

Reason for choice

Set 2

Reason for choice

[2]

© UCLES 2012 0478/02/SP/15 [Turn over


6

(d) (i) Explain how you select the student with the highest score (Task 3). You may include
pseudocode or programming statements to help illustrate your explanation.

[5]

(ii) How does your program work when there is more than one student having the highest
score? Explain using your method given in part (d)(i).

[1]

© UCLES 2012 0478/02/SP/15


7

Section B

2 Jatinder uses Internet banking.


This pseudocode checks her PIN.

c ← 0
INPUT PIN
x ← PIN
REPEAT
x ← x/10
c ← c + 1
UNTIL x < 1
IF c <> 5
THEN
PRINT “error in PIN entered”
ELSE
PRINT “PIN OK”
ENDIF

(a) What value of c and what message would be output if the following PINs were entered?

5 1 0 2 0 Value of c:

Message:

5120 Value of c:

Message: [2]

(b) What type of validation check is being carried out here?

[1]

© UCLES 2012 0478/02/SP/15 [Turn over


8

3 The flowchart inputs the size of a number of car engines; a value of –1 stops the input.

This information is output: average engine size and number of engines with size > 1.5

START

Engine ← 0
Count ← 0
Number ← 0

INPUT Size

is Size Yes OUTPUT


Average ← Engine/Number
= –1 ? Average, Count

No

STOP
is Size Yes
Count ← Count + 1
> 1.5 ?

No

Number ← Number + 1

Engine ← Engine + Size

© UCLES 2012 0478/02/SP/15


9

Complete the trace table for the input data.

1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1

Engine Count Number Size Average OUTPUT

[6]

© UCLES 2012 0478/02/SP/15 [Turn over


10

4 Read this section of program code that inputs twenty (20) numbers and then outputs the largest
number input.

1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20

There are three errors in this code.

Locate these errors and suggest a corrected piece of code.

[3]

© UCLES 2012 0478/02/SP/15


11

BLANK PAGE

© UCLES 2012 0478/02/SP/15 [Turn over


12

5 A floor turtle uses these instructions.

Instruction Meaning

FORWARD d Move d cm forward

BACKWARD d Move d cm backward

LEFT t Turn left t degrees

RIGHT t Turn right t degrees

REPEAT n Repeat the next set of instructions n times

ENDREPEAT End of REPEAT loop

PENUP Raise the pen

PENDOWN Lower the pen

(Each square in the drawing is 10 cm by 10 cm.)

Start Finish

© UCLES 2012 0478/02/SP/15


13

Complete the set of instructions to draw the shape (shown in bold lines).

PENDOWN

LEFT 90

REPEAT

[5]

© UCLES 2012 0478/02/SP/15 [Turn over


14

6 (a) Write an algorithm, using pseudocode or flowchart only, which:

• inputs three numbers


• outputs the largest of the three numbers

[3]

(b) Write an algorithm, using pseudocode or flowchart only, which:

• inputs 1000 numbers


• outputs how many of these numbers were whole numbers (integers)
(You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)

[4]

© UCLES 2012 0478/02/SP/15


15

(c) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]

7 A database was set up to show the properties of certain chemical elements. Part of the database
is shown below.

Name of Element Atomic Atomic Melting Boiling State at


element symbol number weight point (C) point (C) room temp

oxygen O 8 16 –218 –183 gas

iron Fe 26 56 1538 2861 solid

mercury Hg 80 201 –38 356 liquid

bromine Br 35 80 –7 59 liquid

osmium Os 76 190 3033 5012 solid

caesium Cs 55 133 28 671 solid

gallium Ga 31 70 30 2204 solid

argon Ar 18 40 –189 –186 gas

silver Ag 47 108 961 2162 solid

(a) How many fields are in each record?

[1]

(b) The following search condition was entered:

(Melting point (C) < 40) AND (Atomic weight > 100)

Using Element symbol only, which records would be output?

[2]

(c) Which field would be best suited as primary key?

[1]

© UCLES 2012 0478/02/SP/15


16

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.

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.

© UCLES 2012 0478/02/SP/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education

COMPUTER SCIENCE 0478/02


Paper 2 Problem-solving and Programming For Examination from 2015
SPECIMEN PRE-RELEASE MATERIAL
No Additional Materials are required.
This material should be given to candidates up to six months before the examination.

READ THESE INSTRUCTIONS FIRST

Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.

This document consists of 2 printed pages.

© UCLES 2012 [Turn over


2

Candidates’ preparation for the examination should include attempting the following practical
program coding tasks.

Write and test a program to complete the three tasks.

TASK 1

Input and store the names and marks for 30 students who have sat three computer science tests.
Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the
names in a one-dimensional array and the marks and total score for each student in one-dimensional
arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume
that the students’ names are unique.

TASK 2

Calculate and store the total score for each student and calculate the average score for the whole
class. Output each student’s name followed by their total score, then output the average score for the
class.

TASK 3

Select the student with the highest score and output their name and score.

Your program must include appropriate prompts for the entry of data. Error messages and other
output need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

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.

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.

© UCLES 2012 0478/02/SP/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education

COMPUTER SCIENCE 0478/02


Paper 2 Problem-solving and Programming For Examination from 2015
SPECIMEN PAPER
1 hour 45 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.

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.
Calculators must not be used in this paper.

Answer all questions.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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.

This document consists of 13 printed pages and 3 blank pages.

© UCLES 2012 [Turn over


2

BLANK PAGE

© UCLES 2012 0478/02/SP/15


3

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 Section A Question 1.

Pre-release material

Write and test a program to complete the three tasks.

TASK 1

Input and store the names and marks for 30 students who have sat three computer science tests.
Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the
names in a one-dimensional array and the marks and total score for each student in one-dimensional
arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume
that the students’ names are unique.

TASK 2

Calculate and store the total score for each student and calculate the average score for the whole
class. Output each student’s name followed by their total score, then output the average score for the
class.

TASK 3

Select the student with the highest score and output their name and score.

Your program must include appropriate prompts for the entry of data. Error messages and other
output need to be set out clearly and understandably. All variables, constants and other identifiers
must have meaningful names. Each task must be fully tested.

© UCLES 2012 0478/02/SP/15 [Turn over


4

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare the array to store the students’ names.

[1]

(ii) Declare the arrays to store each student’s marks and total score.

[2]

(b) (i) Show the design of your algorithm to complete Task 1 and Task 2 using pseudocode,
programming statements or a flowchart. Do not include any of the validation checks in
your algorithm.

[8]

© UCLES 2012 0478/02/SP/15


5

(ii) Comment on the efficiency of your design.

[1]

(c) Show two different sets of student data that you could use to check the validation used in
Task 1. Explain why you chose each data set.

Set 1

Reason for choice

Set 2

Reason for choice

[2]

© UCLES 2012 0478/02/SP/15 [Turn over


6

(d) (i) Explain how you select the student with the highest score (Task 3). You may include
pseudocode or programming statements to help illustrate your explanation.

[5]

(ii) How does your program work when there is more than one student having the highest
score? Explain using your method given in part (d)(i).

[1]

© UCLES 2012 0478/02/SP/15


7

Section B

2 Jatinder uses Internet banking.


This pseudocode checks her PIN.

c ← 0
INPUT PIN
x ← PIN
REPEAT
x ← x/10
c ← c + 1
UNTIL x < 1
IF c <> 5
THEN
PRINT “error in PIN entered”
ELSE
PRINT “PIN OK”
ENDIF

(a) What value of c and what message would be output if the following PINs were entered?

5 1 0 2 0 Value of c:

Message:

5120 Value of c:

Message: [2]

(b) What type of validation check is being carried out here?

[1]

© UCLES 2012 0478/02/SP/15 [Turn over


8

3 The flowchart inputs the size of a number of car engines; a value of –1 stops the input.

This information is output: average engine size and number of engines with size > 1.5

START

Engine ← 0
Count ← 0
Number ← 0

INPUT Size

is Size Yes OUTPUT


Average ← Engine/Number
= –1 ? Average, Count

No

STOP
is Size Yes
Count ← Count + 1
> 1.5 ?

No

Number ← Number + 1

Engine ← Engine + Size

© UCLES 2012 0478/02/SP/15


9

Complete the trace table for the input data.

1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1

Engine Count Number Size Average OUTPUT

[6]

© UCLES 2012 0478/02/SP/15 [Turn over


10

4 Read this section of program code that inputs twenty (20) numbers and then outputs the largest
number input.

1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20

There are three errors in this code.

Locate these errors and suggest a corrected piece of code.

[3]

© UCLES 2012 0478/02/SP/15


11

BLANK PAGE

© UCLES 2012 0478/02/SP/15 [Turn over


12

5 A floor turtle uses these instructions.

Instruction Meaning

FORWARD d Move d cm forward

BACKWARD d Move d cm backward

LEFT t Turn left t degrees

RIGHT t Turn right t degrees

REPEAT n Repeat the next set of instructions n times

ENDREPEAT End of REPEAT loop

PENUP Raise the pen

PENDOWN Lower the pen

(Each square in the drawing is 10 cm by 10 cm.)

Start Finish

© UCLES 2012 0478/02/SP/15


13

Complete the set of instructions to draw the shape (shown in bold lines).

PENDOWN

LEFT 90

REPEAT

[5]

© UCLES 2012 0478/02/SP/15 [Turn over


14

6 (a) Write an algorithm, using pseudocode or flowchart only, which:

• inputs three numbers


• outputs the largest of the three numbers

[3]

(b) Write an algorithm, using pseudocode or flowchart only, which:

• inputs 1000 numbers


• outputs how many of these numbers were whole numbers (integers)
(You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)

[4]

© UCLES 2012 0478/02/SP/15


15

(c) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]

7 A database was set up to show the properties of certain chemical elements. Part of the database
is shown below.

Name of Element Atomic Atomic Melting Boiling State at


element symbol number weight point (C) point (C) room temp

oxygen O 8 16 –218 –183 gas

iron Fe 26 56 1538 2861 solid

mercury Hg 80 201 –38 356 liquid

bromine Br 35 80 –7 59 liquid

osmium Os 76 190 3033 5012 solid

caesium Cs 55 133 28 671 solid

gallium Ga 31 70 30 2204 solid

argon Ar 18 40 –189 –186 gas

silver Ag 47 108 961 2162 solid

(a) How many fields are in each record?

[1]

(b) The following search condition was entered:

(Melting point (C) < 40) AND (Atomic weight > 100)

Using Element symbol only, which records would be output?

[2]

(c) Which field would be best suited as primary key?

[1]

© UCLES 2012 0478/02/SP/15


16

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.

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.

© UCLES 2012 0478/02/SP/15


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 7 8 3 1 6 9 9 9 2 5 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LEG/SW) 106771/3
© UCLES 2016 [Turn over
2

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

The manager of a parcel delivery service needs a program to check the size and weight of parcels
to determine which parcels can be accepted for delivery.

Write and test a program for the manager.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Check the size and weight of a single parcel

Each parcel must obey the following rules to be accepted for delivery:
• each dimension must be no more than 80 cm
• the sum of the three dimensions must be no more than 200 cm
• the weight of the parcel must be between one and ten kilograms inclusive

Input and store the weight and dimensions for one parcel. All the dimensions and the weight must
be validated on entry and an unsuitable parcel rejected.

Output if the parcel is accepted or rejected. If rejected, output all the reasons why the parcel was
rejected.

TASK 2 – Check a customer’s consignment of parcels

Input and store the number of parcels in the consignment. Calculate the number of parcels accepted
and the total weight of the parcels accepted. For each parcel that was rejected, output all the
reasons why that parcel was rejected.

Output the number of parcels accepted and the total weight of parcels accepted.
Output the number of parcels rejected.

TASK 3 – Calculate the price for a customer’s consignment of parcels

Extend TASK 2 to also calculate the price for each parcel, using the following rules:
• 1 kg to 5 kg inclusive costs $10
• Each 100 grams over 5 kg, up to 10 kg, costs an extra $0.10

Your output should also include the price for each parcel accepted and the total price of the
consignment.

© UCLES 2016 0478/21/M/J/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For each of the variables that you have used to record dimensions of the parcels in Task 1,
state the name, type and its use.

Variable 1 name .................................................................................................................

Type ....................................................................................................................................

Use .....................................................................................................................................

Variable 2 name .................................................................................................................

Type ....................................................................................................................................

Use .....................................................................................................................................

Variable 3 name .................................................................................................................

Type ....................................................................................................................................

Use .................................................................................................................................[3]

(ii) State two constants that you could have used for Task 1. Give the value that would be
assigned to each one.

Constant 1 name ................................................................................................................

Value 1 ...............................................................................................................................

Constant 2 name ................................................................................................................

Value 2 ...........................................................................................................................[2]

© UCLES 2016 0478/21/M/J/16 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2016 0478/21/M/J/16


5

(c) Give three different data sets that could be used to check your validation rules for Task 1.
Explain why you chose each data set.

Data set 1 ..................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

Data set 2 ..................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

Data set 3 ..................................................................................................................................

Reason for choice ......................................................................................................................

...............................................................................................................................................[6]

(d) Explain how your program calculates the price for a consignment (part of Task 3). You may
include programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/21/M/J/16 [Turn over


6

Section B

2 Read this section of program code that inputs 10 positive numbers and then outputs the smallest
number input.

1 Small = 1000
2 Counter = 0
3 REPEAT
4 INPUT Num
5 IF Num < Small THEN Small = Num
6 Counter = Counter + 1
7 UNTIL Counter = 10
8 PRINT Small

(i) Identify three changes you would need to make to find the largest number input instead
of the smallest number.

1 .........................................................................................................................................

...........................................................................................................................................

2 .........................................................................................................................................

...........................................................................................................................................

3 .........................................................................................................................................

.......................................................................................................................................[3]

(ii) Rewrite the program code with your changes.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2016 0478/21/M/J/16


7

3 A program will be written to store information about members of a swimming club.

The following membership details will be recorded:


• Name
• Gender
• Status:
• Senior
• Junior
• Fee
• Team member (Yes or No)

(i) Choose a suitable data type for each of the membership details to be recorded.

Membership details Data type

Name

Gender

Status

Fee

Team member
[5]

(ii) The swimming club has 50 members.

State the data structure that would be most suitable to use and give a reason for your
choice.

Data structure .....................................................................................................................

Reason ...............................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 0478/21/M/J/16 [Turn over


8

4 The flowchart below inputs the height of children who want to ride on a rollercoaster. Children
under 1.2 metres are rejected. The ride starts when eight children have been accepted.

67$57

5LGHUV
5HMHFW

,1387
+HLJKW

,V <HV
+HLJKW 5HMHFW5HMHFW
"

1R

5LGHUV5LGHUV

1R 5LGHUV <HV 287387


" 5HDG\WRJR 5HMHFW

(1'

© UCLES 2016 0478/21/M/J/16


9

Complete the trace table for the input data:

1.4, 1.3, 1.1, 1.3, 1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1.0

Riders Reject Height OUTPUT

[4]

© UCLES 2016 0478/21/M/J/16 [Turn over


10

5 REPEAT ... UNTIL is one type of loop structure.

Identify and describe two other types of loop structure that you could use when writing
pseudocode.

Loop structure 1 .........................................................................................................................

Description .................................................................................................................................

...................................................................................................................................................

Loop structure 2 .........................................................................................................................

Description .................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/21/M/J/16


11

6 A database, STAFFPHONE, was set up to show the telephone extension numbers for members of
staff working in a department store.

Name Department Extension number


Jane Smith Toys 129
Sue Wong Books 124
David Chow Toys 129
Amy Tang Household 123
Joe Higgs Books 124
Jane Smith Shoes 125
Adel Abur Shoes 125
Peter Patel Toys 129

(a) Explain why none of the fields in the database can be used as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) State a field that could be added as a primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Use the query-by-example grid below to provide a list of all members of staff, in alphabetical
order, grouped by department.

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2016 0478/21/M/J/16


12

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.

© UCLES 2016 0478/21/M/J/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 9 6 2 0 1 2 8 5 4 9 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LK/SW) 106762/3
© UCLES 2016 [Turn over
2

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

The manager of a building materials delivery service needs a program to check the contents and
weight of sacks to ensure that correct orders are made up for delivery. A price for the order will be
calculated.

Write and test a program for the manager.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Check the contents and weight of a single sack

Each sack must obey the following rules to be accepted:

• contain cement, gravel or sand, with a letter on the side for easy identification
o C - cement
o G - gravel
o S - sand
• sand or gravel must weigh over 49.9 and under 50.1 kilograms
• cement must weigh over 24.9 and under 25.1 kilograms

Input and store the weight and contents for one sack. The contents must be checked and an incorrect
sack rejected. The weight must be validated on entry and an overweight or underweight sack rejected.

Output the contents and weight of an accepted sack. If a sack is rejected, output the reason(s).

TASK 2 – Check a customer’s order for delivery

Input and store the number of sacks of each type required for the order. Use TASK 1 to check the
contents and weight of each sack. Ensure that the delivery contains the correct number and type of
sacks for the order.

Output the total weight of the order.


Output the number of sacks rejected from the order.

TASK 3 – Calculate the price for a customer’s order

Extend TASK 2 to calculate a price for an order. Prices for the sacks are as follows:

• regular price for each sack


o cement, $3
o gravel, $2
o sand, $2
• discount price for a special pack containing 1 sack of cement, 2 sacks of sand and 2 sacks of
gravel, $10

Calculate and output the regular price for the order. Check how many special packs are in the order. If
a discount price applies then output the new price for the order and the amount saved.

© UCLES 2016 0478/22/M/J/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For three of the variables that you have used in Task 2, state the name, type and its use.

Variable 1 name ................................................................................................................

Type ...................................................................................................................................

Use ....................................................................................................................................

Variable 2 name ................................................................................................................

Type ...................................................................................................................................

Use ....................................................................................................................................

Variable 3 name ................................................................................................................

Type ...................................................................................................................................

Use ................................................................................................................................[3]

(ii) State three constants that you could have used for Task 1. Give the value that would be
assigned to each one.

Constant 1 name ...............................................................................................................

Value 1 ..............................................................................................................................

Constant 2 name ...............................................................................................................

Value 2 ..............................................................................................................................

Constant 3 name ...............................................................................................................

Value 3 ..........................................................................................................................[3]

© UCLES 2016 0478/22/M/J/16 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that the weight and contents have already been checked and
accepted in Task 1. You do not need to output the number of sacks rejected.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2016 0478/22/M/J/16


5

(c) (i) Give two different data values that could be used to check your validation rules for sand
in Task 1. Explain why you chose each value.

Sand data value 1 .............................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

Sand data value 2 .............................................................................................................

Reason for choice .............................................................................................................

.......................................................................................................................................[2]

(ii) Give two different data values that could be used to check your validation rules for
cement in Task 1. Explain why you chose each value.

Cement data value 1 ..........................................................................................................

Reason for choice ..............................................................................................................

...........................................................................................................................................

Cement data value 2 ..........................................................................................................

Reason for choice ..............................................................................................................

.......................................................................................................................................[2]

(d) Explain how your program calculates the price for an order (Task 3). You may include
programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2016 0478/22/M/J/16 [Turn over


6

Section B

2 Read this section of program code that inputs 10 positive numbers and then outputs the total.

1 Total = 0
2 Counter = 0
3 REPEAT
4 INPUT Num
5 Total = Total + Num
6 PRINT Total
7 Counter = Counter + 1
8 UNTIL Counter = 10

This code works, but it is inefficient.

(i) Suggest three improvements that could be made.

1 .................................................................................................................................................

...................................................................................................................................................

2 .................................................................................................................................................

...................................................................................................................................................

3 .................................................................................................................................................

...............................................................................................................................................[3]

(ii) Rewrite the program code with your improvements.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2016 0478/22/M/J/16


7

3 The flowchart below calculates the number of tins of paint required to paint walls. The flowchart
inputs the height and width of a wall in metres, the number of doors and the number of windows.
A value of –1 for the height stops the input.

START

Area 0
Tins 0

INPUT Height,
Width, Doors,
Windows

Is Yes
Height Tins INT(Area/10 + 0.5)
= –1?

No

OUTPUT Tins
Area Area + Height * Width
– Doors * 1.5 – Windows

END

Complete the trace table for the input data:

3, 5, 1, 0, 3, 7, 0, 0, 3, 5, 0, 3, 3, 7, 1, 1, –1, 0, 0, 0

Area Tins Height Width Doors Windows

[4]

© UCLES 2016 0478/22/M/J/16 [Turn over


8

4 Four statement types and four examples are shown below.

Draw a line to connect each statement type to the correct example.

Statement type Example

Assignment FOR X 1 TO 10

Iteration READ X

Input PRINT X

Output X Y + Z

[3]

5 A programmer writes a program to store a patient’s temperature every hour for a day.

State the data structure that would be most suitable to use and give the reason for your choice.

Data structure ...................................................................................................................................

Reason ..............................................................................................................................................

......................................................................................................................................................[2]

6 Identify two different selection statements that you can use when writing pseudocode.

1 ........................................................................................................................................................

..........................................................................................................................................................

2 ........................................................................................................................................................

......................................................................................................................................................[2]

© UCLES 2016 0478/22/M/J/16


9

Question 7 begins on page 10.

© UCLES 2016 0478/22/M/J/16 [Turn over


10

7 A database, SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale from
an online furniture warehouse. Part of the database is shown below.

Brochure Number Number


Description Material Colour Price in $
Number of Seats of Pieces

Sofa SF17 2 1 Leather Red 950

Sofa SF19 3 1 Vinyl Black 1,000

Suite SU10 4 3 Velvet Green 1,500

Suite SU23 5 3 Leather Brown 950

Recliner chair RC01 1 1 Leather Cream 600

Chair CH16 1 1 Vinyl Red 250

Recliner sofa RS23 4 1 Leather Cream 1,200

Chair CH10 1 1 Velvet Red 175

(a) How many fields are in each record?

...............................................................................................................................................[1]

(b) State which field you would choose for the primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) State the data type you would choose for each of the following fields.

Number of Seats .....................................................................................................................

Price in $ ..............................................................................................................................[2]

© UCLES 2016 0478/22/M/J/16


11

(d) The query-by-example grid below selects all the furniture in cream leather.

Field: Description Material Colour Price in $ Brochure Number


Table: SOFASELECT SOFASELECT SOFASELECT SOFASELECT SOFASELECT
Sort: Descending
Show:   
Criteria: = ‘Leather’ = ‘Cream’
or:

Show the output from the query-by-example.

...................................................................................................................................................

...............................................................................................................................................[3]

(e) Complete the query-by-example grid below to select and show the brochure number, material,
colour and price of all the furniture with 3 or more seats.

Field:
Table:
Sort:
Show:
Criteria:
or:

[5]

© UCLES 2016 0478/22/M/J/16


12

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.

© UCLES 2016 0478/22/M/J/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 2 6 3 2 1 1 0 4 5 6 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LK/SW) 124305
© UCLES 2016 [Turn over
2

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

The manager of a parcel delivery service needs a program to check the size and weight of parcels
to determine which parcels can be accepted for delivery.

Write and test a program for the manager.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Check the size and weight of a single parcel

Each parcel must obey the following rules to be accepted for delivery:
• each dimension must be no more than 80 cm
• the sum of the three dimensions must be no more than 200 cm
• the weight of the parcel must be between one and ten kilograms inclusive

Input and store the weight and dimensions for one parcel. All the dimensions and the weight must
be validated on entry and an unsuitable parcel rejected.

Output if the parcel is accepted or rejected. If rejected, output all the reasons why the parcel was
rejected.

TASK 2 – Check a customer’s consignment of parcels

Input and store the number of parcels in the consignment. Calculate the number of parcels accepted
and the total weight of the parcels accepted. For each parcel that was rejected, output all the
reasons why that parcel was rejected.

Output the number of parcels accepted and the total weight of parcels accepted.
Output the number of parcels rejected.

TASK 3 – Calculate the price for a customer’s consignment of parcels

Extend TASK 2 to also calculate the price for each parcel, using the following rules:
• 1 kg to 5 kg inclusive costs $10
• Each 100 grams over 5 kg, up to 10 kg, costs an extra $0.10

Your output should also include the price for each parcel accepted and the total price of the
consignment.

© UCLES 2016 0478/23/M/J/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For each of the variables that you have used to record dimensions of the parcels in Task 1,
state the name, type and its use.

Variable 1 name .................................................................................................................

Type ....................................................................................................................................

Use .....................................................................................................................................

Variable 2 name .................................................................................................................

Type ....................................................................................................................................

Use .....................................................................................................................................

Variable 3 name .................................................................................................................

Type ....................................................................................................................................

Use .................................................................................................................................[3]

(ii) State two constants that you could have used for Task 1. Give the value that would be
assigned to each one.

Constant 1 name ................................................................................................................

Value 1 ...............................................................................................................................

Constant 2 name ................................................................................................................

Value 2 ...........................................................................................................................[2]

© UCLES 2016 0478/23/M/J/16 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2016 0478/23/M/J/16


5

(c) Give three different data sets that could be used to check your validation rules for Task 1.
Explain why you chose each data set.

Data set 1 ..................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

Data set 2 ..................................................................................................................................

Reason for choice ......................................................................................................................

...................................................................................................................................................

Data set 3 ..................................................................................................................................

Reason for choice ......................................................................................................................

...............................................................................................................................................[6]

(d) Explain how your program calculates the price for a consignment (part of Task 3). You may
include programming statements as part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/23/M/J/16 [Turn over


6

Section B

2 Read this section of program code that inputs 10 positive numbers and then outputs the smallest
number input.

1 Small = 1000
2 Counter = 0
3 REPEAT
4 INPUT Num
5 IF Num < Small THEN Small = Num
6 Counter = Counter + 1
7 UNTIL Counter = 10
8 PRINT Small

(i) Identify three changes you would need to make to find the largest number input instead
of the smallest number.

1 .........................................................................................................................................

...........................................................................................................................................

2 .........................................................................................................................................

...........................................................................................................................................

3 .........................................................................................................................................

.......................................................................................................................................[3]

(ii) Rewrite the program code with your changes.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2016 0478/23/M/J/16


7

3 A program will be written to store information about members of a swimming club.

The following membership details will be recorded:


• Name
• Gender
• Status:
• Senior
• Junior
• Fee
• Team member (Yes or No)

(i) Choose a suitable data type for each of the membership details to be recorded.

Membership details Data type

Name

Gender

Status

Fee

Team member
[5]

(ii) The swimming club has 50 members.

State the data structure that would be most suitable to use and give a reason for your
choice.

Data structure .....................................................................................................................

Reason ...............................................................................................................................

.......................................................................................................................................[2]

© UCLES 2016 0478/23/M/J/16 [Turn over


8

4 The flowchart below inputs the height of children who want to ride on a rollercoaster. Children
under 1.2 metres are rejected. The ride starts when eight children have been accepted.

67$57

5LGHUV
5HMHFW

,1387
+HLJKW

,V <HV
+HLJKW 5HMHFW5HMHFW
"

1R

5LGHUV5LGHUV

1R 5LGHUV <HV 287387


" 5HDG\WRJR 5HMHFW

(1'

© UCLES 2016 0478/23/M/J/16


9

Complete the trace table for the input data:

1.4, 1.3, 1.1, 1.3, 1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1.0

Riders Reject Height OUTPUT

[4]

© UCLES 2016 0478/23/M/J/16 [Turn over


10

5 REPEAT ... UNTIL is one type of loop structure.

Identify and describe two other types of loop structure that you could use when writing
pseudocode.

Loop structure 1 .........................................................................................................................

Description .................................................................................................................................

...................................................................................................................................................

Loop structure 2 .........................................................................................................................

Description .................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/23/M/J/16


11

6 A database, STAFFPHONE, was set up to show the telephone extension numbers for members of
staff working in a department store.

Name Department Extension number


Jane Smith Toys 129
Sue Wong Books 124
David Chow Toys 129
Amy Tang Household 123
Joe Higgs Books 124
Jane Smith Shoes 125
Adel Abur Shoes 125
Peter Patel Toys 129

(a) Explain why none of the fields in the database can be used as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) State a field that could be added as a primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Use the query-by-example grid below to provide a list of all members of staff, in alphabetical
order, grouped by department.

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2016 0478/23/M/J/16


12

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.

© UCLES 2016 0478/23/M/J/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 9 1 6 4 0 1 0 2 0 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LEG/SW) 106619/4
© UCLES 2016 [Turn over
2

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

The headteacher of a school needs a program to record and count the votes for a class captain.
Each student in the class will be allowed one vote. There can be up to 30 students in a class.

Write and test a program for the headteacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Set up the voting

Each class can choose from up to four different students as candidates for their class captain. Set
up a routine that allows:

• between two and four different candidate names to be input and stored
• the candidate names to be displayed with a number (1, 2, 3 or 4) beside each name
• a choice of 1, 2, 3 or 4 to be entered to record a vote; all other entries are rejected
• up to four totals set to zero ready to record the votes
• a maximum of 30 votes to be cast

TASK 2 – Record and count each vote

Input a number 1, 2, 3 or 4; add 1 to the appropriate total.

Output the name of the candidate voted for or output ‘invalid vote’ if a vote is rejected.

TASK 3 – Show the result

When all the votes have been cast, display the candidates’ names with their totals in descending
order of totals. If there is a clear winner, display the candidate’s name with the words ‘NEW CLASS
CAPTAIN’ beside it; otherwise display ‘NO OVERALL WINNER’.

© UCLES 2016 0478/21/O/N/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

For four of the variables, constants or arrays that you used in Task 1, state the name, data
structure, data type and its use.

Name 1 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 2 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 3 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 4 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ........................................................................................................................................[8]

© UCLES 2016 0478/21/O/N/16 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed and that there are three
candidates for class captain.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/21/O/N/16


5

(c) Explain how you show the result (Task 3). You may include programming statements as part
of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

(d) Explain how you could extend your solution to deal with the case of ‘NO OVERALL WINNER’.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2016 0478/21/O/N/16 [Turn over


6

Section B

2 Read this section of program code that:

• inputs 10 numbers
• checks whether each number is within a specified range
• totals the numbers within the range and outside the range

1 InRange = 0
2 OutRange = 1000
3 FOR Count = 1 TO 10
4 INPUT Num
5 IF Num > 10 AND Num < 20 THEN InRange = InRange + 1
6 ELSE OutRange = OutRange - 1
7 Count = Count + 1
8 NEXT X
9 PRINT InRange, OutRange

(a) There are four errors in this code.

Locate these errors and suggest a correction to remove each error.

Error 1 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction ..................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/21/O/N/16


7

(b) Decide, with reasons, whether the numbers 10 and 20 are within or outside the range.

Within Outside
Number Reason
range (✓) range (✓)

10
……………………………………………………………………..

……………………………………………………………………..

20
……………………………………………………………………..

……………………………………………………………………..

[4]

© UCLES 2016 0478/21/O/N/16 [Turn over


8

3 The flowchart below inputs the price of an item under $10. The change from a $10 note is output.
Any amount less than 5 cents is rounded up to 5 cents.

The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5

START

INPUT Price

Change 10 – Price

Is
Change Yes Dollars INT(Change)
>= 1?

No Change Change – INT(Change)

OUTPUT Dollars,
" dollars"

Is
Change Yes
Change Change – 0.5
>= 0.5?

No OUTPUT "One 50
cent coin"

TenCents INT(Change * 10 + 0.5)

OUTPUT TenCents,
" ten cent coins"

Is Change*10 – Yes OUTPUT "One 5


TenCents cent coin"
> 0?

No

END

© UCLES 2016 0478/21/O/N/16


9

Complete the trace table for the input data: 6.29

Price Change Dollars TenCents OUTPUT

[5]

4 Four validation checks and four descriptions are shown below.

Draw a line to link each validation check to the correct description.

Validation check Description

Numbers between two


Presence check
given values are accepted

Data is of a particular
Range check
specified type

Data contains an exact


Type check
number of characters

Ensures that some data


Length check
have been entered
[3]

© UCLES 2016 0478/21/O/N/16 [Turn over


10

5 REPEAT ... UNTIL and WHILE ... DO ... ENDWHILE are two different loop
structures you can use when writing pseudocode.

Explain, using examples, why you would choose to use each type of loop.

Example 1 .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice .............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example 2 .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice .............................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[6]

© UCLES 2016 0478/21/O/N/16


11

6 A database, THEATRETOURS, was set up to show the tour dates, towns, number of seats and
prices in local currency for a Shakespeare play.

Town Tour Date Number of Seats Price Local Currency


Wigan 18/08/2016 120 15.00
Dumfries 20/08/2016 160 12.50
Turin 25/08/2016 200 17.00
Macon 27/08/2016 75 18.00
Bordeaux 29/08/2016 170 20.00
Algiers 01/09/2016 125 1350.00
Windhoek 05/09/2016 65 90.00
Windhoek 06/09/2016 65 90.00
Port Elizabeth 10/09/2016 200 110.00

(a) Explain why none of the fields in the database can be used as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) State a field that could be added as a primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Use the query-by-example grid below to provide a list of tour dates and seat prices in
alphabetical order of town.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2016 0478/21/O/N/16


12

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.

© UCLES 2016 0478/21/O/N/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 0 3 5 1 1 2 3 4 2 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NF/FD) 126910/4 R
© UCLES 2016 [Turn over
2

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

The manager of a supermarket needs a program to record donations to charity. Each customer has
the choice of three charities to donate to, and 1% of their shopping bill will be donated to the chosen
charity.

Write and test a program for the manager.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Set up the donation system

Set up a routine that allows:


• the names of three charities to be input and stored
• the charity names to be displayed with a number (1, 2 or 3) beside each name
• a choice of 1, 2 or 3 to be entered to choose the charity, all other entries rejected
• the value of a customer’s shopping bill to be entered
• the donation to be calculated
• three totals to be set to zero ready to total each charity donation

TASK 2 – Record and total each donation

For a customer’s shopping bill:


• input a charity choice of 1, 2 or 3
• input the value of a customer’s shopping bill
• calculate the donation
• add the donation to the appropriate total

Output the name of the charity and the amount donated.

TASK 3 – Show the totals so far

Extend TASK 2 to accept:


• donations from more customers
• a charity choice of -1 to show the totals so far

Display the charities’ names and the totals in descending order of totals.
Calculate a grand total of all three totals.
Output ‘GRAND TOTAL DONATED TO CHARITY’ and the amount of the grand total.

© UCLES 2016 0478/22/O/N/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For three of the variables that you have used in Task 1, state the name, type and its use.

Variable 1 name ................................................................................................................

Type ...................................................................................................................................

Use ....................................................................................................................................

Variable 2 name ................................................................................................................

Type ...................................................................................................................................

Use ....................................................................................................................................

Variable 3 name ................................................................................................................

Type ...................................................................................................................................

Use ............................................................................................................................... [3]

(ii) Name and describe the data structure(s) that you have used to store the donation totals
for each charity. Explain why you chose your data structure(s).

Name of data structure(s) .................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

Reason ..............................................................................................................................

...................................................................................................................................... [3]

© UCLES 2016 0478/22/O/N/16 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

© UCLES 2016 0478/22/O/N/16


5

(c) Explain how you show the totals so far (Task 3). You may include programming statements as
part of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]

(d) Explain how you would change your solution for Task 1 to allow the number of charities to be
set to two, three or four by the manager.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

© UCLES 2016 0478/22/O/N/16 [Turn over


6

Section B

2 Read this section of program code that inputs positive numbers, discards any negative numbers
and then outputs the average. An input of zero ends the process.

1 Total = 0
2 Counter = 100
3 REPEAT
4 REPEAT
5 INPUT Num
6 UNTIL Num < 0
7 Total = Total + 1
8 Counter = Counter + Num
9 UNTIL Num = 0
10 Average = Total / (Counter - 1)
11 Print Average

There are four errors in this code.

Locate these errors and suggest a correction to remove each error.

Error 1 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 2 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 3 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 4 ..............................................................................................................................................

Correction .........................................................................................................................................

..................................................................................................................................................... [8]

© UCLES 2016 0478/22/O/N/16


7

3 The flowchart below inputs an integer. The predefined function DIV gives the value of the division,
for example Z ← 11 DIV 3 gives the value Z = 3. The predefined function MOD gives the value
of the remainder, for example Z ← 11 MOD 3 gives the value Z = 2.

67$57

,1387;

1R
,V;!
"
<HV

$ ;',9
% ;02' 287387;

287387% (1'

; $

Complete a trace table for each of the two input values 33 and 75.

Trace table for input value 33

X A B OUTPUT

Trace table for input value 75

X A B OUTPUT

[4]
© UCLES 2016 0478/22/O/N/16 [Turn over
8

4 IF ... THEN ... ELSE ... ENDIF and CASE ... OF ... OTHERWISE ... ENDCASE
are two different conditional statements that you can use when writing pseudocode.

Explain, using examples, why you would choose to use each conditional statement.

Example 1 ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example 2 ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice ............................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [6]

© UCLES 2016 0478/22/O/N/16


9

Question 5 begins on page 10.

© UCLES 2016 0478/22/O/N/16 [Turn over


10

5 A database, PLAYPRODUCTION, was set up to show the performance dates, prices and number
of seats available at a theatre specialising in Shakespeare productions.

Number Number
Performance Price Stalls Price Circle
Play Seats Seats
Date Seats $ Seats $
Stalls Circle
As You Like It 01/07/2016 120 90 20.00 30.00
As You Like It 02/07/2016 85 45 30.00 40.00
As You Like It 09/07/2016 31 4 30.00 40.00
Macbeth 14/07/2016 101 56 25.00 35.00
Macbeth 15/07/2016 50 34 25.00 35.00
Macbeth 16/07/2016 12 5 35.00 50.00
Julius Caesar 22/07/2016 67 111 20.00 20.00
Julius Caesar 23/07/2016 21 24 15.00 15.00
A Comedy of Errors 30/07/2016 45 36 35.00 45.00

(a) Give the number of fields that are in each record.

.............................................................................................................................................. [1]

(b) State the data type you would choose for each of the following fields.

Play ..........................................................................................................................................

Number Seats Stalls ...............................................................................................................

Price Stalls Seats $ ............................................................................................................ [3]

(c) The query-by-example grid below selects all the productions with more than 100 seats left in
either the stalls or the circle.

Field: Play Performance Date Number Seats Stalls Number Seats Circle

Table: PLAYPRODUCTION PLAYPRODUCTION PLAYPRODUCTION PLAYPRODUCTION

Sort: Ascending

Show:  
Criteria: > 100

or: > 100

Show what would be output from the query-by-example.

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]
© UCLES 2016 0478/22/O/N/16
11

(d) Complete the query-by-example grid below to select all the productions with at least six seats
left in the circle and show the Play, Performance Date and Price Circle Seats $ in Performance
Date order.

Field:

Table:

Sort:

Show:
Criteria:

or:
[5]

© UCLES 2016 0478/22/O/N/16


12

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.

© UCLES 2016 0478/22/O/N/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 8 4 6 4 4 6 6 7 1 8 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2016
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LK/SW) 125705/1
© UCLES 2016 [Turn over
2

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

The headteacher of a school needs a program to record and count the votes for a class captain.
Each student in the class will be allowed one vote. There can be up to 30 students in a class.

Write and test a program for the headteacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Set up the voting

Each class can choose from up to four different students as candidates for their class captain. Set
up a routine that allows:

• between two and four different candidate names to be input and stored
• the candidate names to be displayed with a number (1, 2, 3 or 4) beside each name
• a choice of 1, 2, 3 or 4 to be entered to record a vote; all other entries are rejected
• up to four totals set to zero ready to record the votes
• a maximum of 30 votes to be cast

TASK 2 – Record and count each vote

Input a number 1, 2, 3 or 4; add 1 to the appropriate total.

Output the name of the candidate voted for or output ‘invalid vote’ if a vote is rejected.

TASK 3 – Show the result

When all the votes have been cast, display the candidates’ names with their totals in descending
order of totals. If there is a clear winner, display the candidate’s name with the words ‘NEW CLASS
CAPTAIN’ beside it; otherwise display ‘NO OVERALL WINNER’.

© UCLES 2016 0478/23/O/N/16


3

1 (a) All variables, constants and other identifiers should have meaningful names.

For four of the variables, constants or arrays that you used in Task 1, state the name, data
structure, data type and its use.

Name 1 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 2 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 3 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ............................................................................................................................................

Name 4 ......................................................................................................................................

Data structure ............................................................................................................................

Data type ...................................................................................................................................

Use ........................................................................................................................................[8]

© UCLES 2016 0478/23/O/N/16 [Turn over


4

(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed and that there are three
candidates for class captain.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/23/O/N/16


5

(c) Explain how you show the result (Task 3). You may include programming statements as part
of your explanation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

(d) Explain how you could extend your solution to deal with the case of ‘NO OVERALL WINNER’.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2016 0478/23/O/N/16 [Turn over


6

Section B

2 Read this section of program code that:

• inputs 10 numbers
• checks whether each number is within a specified range
• totals the numbers within the range and outside the range

1 InRange = 0
2 OutRange = 1000
3 FOR Count = 1 TO 10
4 INPUT Num
5 IF Num > 10 AND Num < 20 THEN InRange = InRange + 1
6 ELSE OutRange = OutRange - 1
7 Count = Count + 1
8 NEXT X
9 PRINT InRange, OutRange

(a) There are four errors in this code.

Locate these errors and suggest a correction to remove each error.

Error 1 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction ..................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2016 0478/23/O/N/16


7

(b) Decide, with reasons, whether the numbers 10 and 20 are within or outside the range.

Within Outside
Number Reason
range (✓) range (✓)

10
……………………………………………………………………..

……………………………………………………………………..

20
……………………………………………………………………..

……………………………………………………………………..

[4]

© UCLES 2016 0478/23/O/N/16 [Turn over


8

3 The flowchart below inputs the price of an item under $10. The change from a $10 note is output.
Any amount less than 5 cents is rounded up to 5 cents.

The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5

START

INPUT Price

Change 10 – Price

Is
Change Yes Dollars INT(Change)
>= 1?

No Change Change – INT(Change)

OUTPUT Dollars,
" dollars"

Is
Change Yes
Change Change – 0.5
>= 0.5?

No OUTPUT "One 50
cent coin"

TenCents INT(Change * 10 + 0.5)

OUTPUT TenCents,
" ten cent coins"

Is Change*10 – Yes OUTPUT "One 5


TenCents cent coin"
> 0?

No

END

© UCLES 2016 0478/23/O/N/16


9

Complete the trace table for the input data: 6.29

Price Change Dollars TenCents OUTPUT

[5]

4 Four validation checks and four descriptions are shown below.

Draw a line to link each validation check to the correct description.

Validation check Description

Numbers between two


Presence check
given values are accepted

Data is of a particular
Range check
specified type

Data contains an exact


Type check
number of characters

Ensures that some data


Length check
have been entered
[3]

© UCLES 2016 0478/23/O/N/16 [Turn over


10

5 REPEAT ... UNTIL and WHILE ... DO ... ENDWHILE are two different loop
structures you can use when writing pseudocode.

Explain, using examples, why you would choose to use each type of loop.

Example 1 .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice .............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example 2 .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason for choice .............................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[6]

© UCLES 2016 0478/23/O/N/16


11

6 A database, THEATRETOURS, was set up to show the tour dates, towns, number of seats and
prices in local currency for a Shakespeare play.

Town Tour Date Number of Seats Price Local Currency


Wigan 18/08/2016 120 15.00
Dumfries 20/08/2016 160 12.50
Turin 25/08/2016 200 17.00
Macon 27/08/2016 75 18.00
Bordeaux 29/08/2016 170 20.00
Algiers 01/09/2016 125 1350.00
Windhoek 05/09/2016 65 90.00
Windhoek 06/09/2016 65 90.00
Port Elizabeth 10/09/2016 200 110.00

(a) Explain why none of the fields in the database can be used as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) State a field that could be added as a primary key.

...................................................................................................................................................

Give a reason for choosing this field.

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Use the query-by-example grid below to provide a list of tour dates and seat prices in
alphabetical order of town.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2016 0478/23/O/N/16


12

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.

© UCLES 2016 0478/23/O/N/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
*0123456789*

COMPUTER SCIENCE 0478/02


Paper 2 Problem-solving and Programming For Examination from 2016
SPECIMEN PAPER
1 hour 45 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.

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.
Calculators must not be used in this paper.

Answer all questions.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is accredited for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 13 printed pages and 3 blank pages.

© UCLES 2014 [Turn over


2

BLANK PAGE

© UCLES 2014 0478/02/SP/16


3

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 Section A Question 1.

Pre-release material

A teacher needs a program to record marks for a class of 30 students who have sat three computer
science tests.

Write and test a program for the teacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Set up arrays

Set-up one dimensional arrays to store:

• Student names
• Student marks for Test 1, Test 2 and Test 3
o Test 1 is out of 20 marks
o Test 2 is out of 25 marks
o Test 3 is out of 35 marks
• Total score for each student

Input and store the names for 30 students. You may assume that the students’ names are unique.

Input and store the students’ marks for Test 1, Test 2 and Test 3. All the marks must be validated on
entry and any invalid marks rejected.

TASK 2 – Calculate

Calculate the total score for each student and store in the array.
Calculate the average total score for the whole class.

Output each student’s name followed by their total score.


Output the average total score for the class.

TASK 3 – Select

Select the student with the highest total score and output their name and total score.

© UCLES 2014 0478/02/SP/16 [Turn over


4

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare the array to store the students’ names.

[1]

(ii) Declare the arrays to store each student’s marks and total score.

[2]

(b) (i) Show the design of your algorithm to complete Task 1 and Task 2 using pseudocode,
programming statements or a flowchart. Do not include any of the validation checks or
input prompts in your algorithm.

[8]

© UCLES 2014 0478/02/SP/16


5

(ii) Comment on the efficiency of your design.

[1]

(c) Show two different sets of student data that you could use to check the validation used in
Task 1. Explain why you chose each data set.

Set 1

Reason for choice

Set 2

Reason for choice

[2]

© UCLES 2014 0478/02/SP/16 [Turn over


6

(d) (i) Explain how you select the student with the highest score (Task 3). You may include
pseudocode or programming statements to help illustrate your explanation.

[5]

(ii) How does your program work when there is more than one student having the highest
score? Explain using your method given in part (d)(i).

[1]

© UCLES 2014 0478/02/SP/16


7

Section B

2 Jatinder uses Internet banking.


This pseudocode checks her PIN.

c ← 0
INPUT PIN
x ← PIN
REPEAT
x ← x/10
c ← c + 1
UNTIL x < 1
IF c <> 5
THEN
PRINT “error in PIN entered”
ELSE
PRINT “PIN OK”
ENDIF

(a) What value of c and what message would be output if the following PINs were entered?

5 1 0 2 0 Value of c:

Message:

5120 Value of c:

Message: [2]

(b) What type of validation check is being carried out here?

[1]

© UCLES 2014 0478/02/SP/16 [Turn over


8

3 The flowchart inputs the size of a number of car engines; a value of –1 stops the input.

This information is output: average engine size and number of engines with size > 1.5

START

Engine ← 0
Count ← 0
Number ← 0

INPUT Size

is Size Yes OUTPUT


Average ← Engine/Number
= –1 ? Average, Count

No

STOP
is Size Yes
Count ← Count + 1
> 1.5 ?

No

Number ← Number + 1

Engine ← Engine + Size

© UCLES 2014 0478/02/SP/16


9

Complete the trace table for the input data.

1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1

Engine Count Number Size Average OUTPUT

[6]

© UCLES 2014 0478/02/SP/16 [Turn over


10

4 Read this section of program code that inputs twenty (20) numbers and then outputs the largest
number input.

1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20

There are three errors in this code.

Locate these errors and suggest a corrected piece of code.

[3]

© UCLES 2014 0478/02/SP/16


11

BLANK PAGE

© UCLES 2014 0478/02/SP/16 [Turn over


12

5 A floor turtle uses these instructions.

Instruction Meaning

FORWARD d Move d cm forward

BACKWARD d Move d cm backward

LEFT t Turn left t degrees

RIGHT t Turn right t degrees

REPEAT n Repeat the next set of instructions n times

ENDREPEAT End of REPEAT loop

PENUP Raise the pen

PENDOWN Lower the pen

(Each square in the drawing is 10 cm by 10 cm.)

Start Finish

© UCLES 2014 0478/02/SP/16


13

Complete the set of instructions to draw the shape (shown in bold lines).

PENDOWN

LEFT 90

REPEAT

[5]

© UCLES 2014 0478/02/SP/16 [Turn over


14

6 (a) Write an algorithm, using pseudocode or flowchart only, which:

• inputs three numbers


• outputs the largest of the three numbers

[3]

(b) Write an algorithm, using pseudocode or flowchart only, which:

• inputs 1000 numbers


• outputs how many of these numbers were whole numbers (integers)
(You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)

[4]

© UCLES 2014 0478/02/SP/16


15

(c) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]

7 A database was set up to show the properties of certain chemical elements. Part of the database
is shown below.

Name of Element Atomic Atomic Melting Boiling State at


element symbol number weight point (C) point (C) room temp

oxygen O 8 16 –218 –183 gas

iron Fe 26 56 1538 2861 solid

mercury Hg 80 201 –38 356 liquid

bromine Br 35 80 –7 59 liquid

osmium Os 76 190 3033 5012 solid

caesium Cs 55 133 28 671 solid

gallium Ga 31 70 30 2204 solid

argon Ar 18 40 –189 –186 gas

silver Ag 47 108 961 2162 solid

(a) How many fields are in each record?

[1]

(b) The following search condition was entered:

(Melting point (C) < 40) AND (Atomic weight > 100)

Using Element symbol only, which records would be output?

[2]

(c) Which field would be best suited as primary key?

[1]

© UCLES 2014 0478/02/SP/16


16

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.

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.

© UCLES 2014 0478/02/SP/16


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 7 7 3 4 2 6 3 8 0 1 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 10 printed pages and 2 blank pages.

DC (SLM/SW) 134136/3
© UCLES 2017 [Turn over
2

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

An experiment has taken place which measures the reaction speeds of students. Each student is
aged from 12 to 16, and belongs to a school house (Saturn or Mars). A program is required to store
the age, school house and reaction time of each student in the school. There are 650 students in the
school. The program should be able to output the reaction times of different student groups.

Write and test a program for the school.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Set up arrays and store records

Set up one-dimensional arrays for the whole school to store the following data:

• The age of each student in whole years


• The school house of each student
• The reaction time of each student

Input and store the records for an appropriate sample of students. Inputs must be validated on
entry and any invalid inputs rejected.

TASK 2 – Output school house based statistics

Using your sample, calculate and output the average reaction times for students in Saturn and
students in Mars.

TASK 3 – Output statistics based on user input

Extend your program to prompt users to input a specific age and school house. Using only records
that match the criteria input, the program should identify, calculate and output:

• The average reaction time


• The slowest reaction time

The output should include a suitable message for each of the reaction times identified.

© UCLES 2017 0478/22/F/M/17


3

1 (a) All variables and other identifiers should have meaningful names.

(i) Declare the array used to store the reaction times for the whole school.

.......................................................................................................................................[1]

(ii) Change this declaration so the array can only hold records for a sample of 50 students.

.......................................................................................................................................[1]

(iii) Explain why an array is an effective data structure for storing the reaction time records.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(b) Write an algorithm to complete Task 1 for the whole school, using either pseudocode,
programming statements or a flowchart. DO NOT include any validation routines.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/22/F/M/17 [Turn over


4

(c) Identify three different types of test data you used to test the validation checks on the age
input in Task 1. For each type, give an example of appropriate data.

Type of test data Example data

[6]

(d) Explain how you calculated and outputted the average reaction time based on the user
inputs of age and school house, as part of Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/22/F/M/17


5

(e) Explain how you would change your solution to Task 3 to output the age of the student with
the fastest reaction time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2017 0478/22/F/M/17 [Turn over


6

Section B

2 Read this section of code that inputs the ages of people entering an event. The input sequence is
ended by inputting a negative value for age. The code outputs the number of people at the event
over the age of 18.

01 Num18 = 0
02 INPUT Age
03 WHILE Age >= 0 DO
04 IF Age >= 18 THEN
05 Num18 = Num18 + Age
06 ENDIF
07 ENDWHILE
08 PRINT Num18 - Age

There are four errors in this code.

Locate these errors and suggest code correction to remove each error.

Error 1 ...............................................................................................................................................

Correction..........................................................................................................................................

..........................................................................................................................................................

Error 2 ...............................................................................................................................................

Correction..........................................................................................................................................

..........................................................................................................................................................

Error 3 ...............................................................................................................................................

Correction..........................................................................................................................................

..........................................................................................................................................................

Error 4 ...............................................................................................................................................

Correction..........................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2017 0478/22/F/M/17


7

3 There is a program that stores the following data:

• EmployeeID, an employee ID which must be two letters followed by 4 numbers, e.g. TY4587
• Manager, whether the employee is a manager or not
• AnnualHoliday, number of whole days’ annual holiday
• PayGrade, the employee’s pay grade which must be a single letter A–F

Complete the following table to identify:

• The most appropriate data type for each variable


• An appropriate validation check for each variable. You must use a different validation check
for each variable.

Variable Data type Appropriate validation check

EmployeeID

Manager

AnnualHoliday

PayGrade

[8]

© UCLES 2017 0478/22/F/M/17 [Turn over


8

4 Study the flowchart.

START

INPUT A OUTPUT B

IS Yes B A
A > 0 ? B B + A C C – 1
C A

No
IS
OUTPUT C <= 1 ? Yes
'Exit'
No

END

Complete the trace table for the input values 4, 3, −1:

A B C OUTPUT

[4]

© UCLES 2017 0478/22/F/M/17


9

5 (a) Rewrite the following pseudocode algorithm using a WHILE … DO … ENDWHILE loop.

INPUT Num
FOR Counter ← 1 TO 12
Num ← Num * Counter
A[Counter] ← Num
NEXT

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) Explain the differences between a WHILE … DO … ENDWHILE and a REPEAT … UNTIL
loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2017 0478/22/F/M/17 [Turn over


10

6 A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.

Device ID Device Type User Purchase Purchase Portable


Date Price ($)
3 Desktop Alan Swales 14/02/2017 1350.00 N

4 Laptop Chantel Law 01/02/2016 1460.00 Y

5 Tablet Abdula Saud 31/12/2016 1000.00 Y

6 Desktop Abdula Saud 14/03/2017 1000.00 N

7 Laptop Alan Swales 15/03/2016 1700.00 Y

8 Tablet Taona Jaji 16/12/2016 470.00 Y

(a) The query-by-example grid below selects certain records.

Field: User Portable Purchase Price ($)

Table: DEVICE DEVICE DEVICE

Sort: Ascending

Show: 3

Criteria: Y >1000

or:

Show what would be the output from the query-by-example.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Complete the query-by-example grid below to select all Desktop devices that were either
purchased before 31/12/2016 or cost under $1000. Only show the Device ID and Device
Type.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

© UCLES 2017 0478/22/F/M/17


11

BLANK PAGE

© UCLES 2017 0478/22/F/M/17


12

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.

© UCLES 2017 0478/22/F/M/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 3 8 1 1 4 3 2 5 8 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 14 printed pages and 2 blank pages.

DC (CW/SW) 131977/3
© UCLES 2017 [Turn over
2

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 teacher is planning a school trip to a theme park at the end of term. You have been asked to write
a program to work out the cost per student, to record those who are going and whether they have
paid. The maximum number of students who can go on the trip is 45.

Write and test a program for the teacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Work out the cost.

The cost of the trip for each student is a share of the cost of a coach plus the cost of entry to the
theme park. The total cost of the coach will be $550. The entry cost to the park is $30 for each
student. The theme park gives one free ticket for every ten that are bought, which must be taken into
consideration. Set up a program that:

• stores the cost of the coach


• stores the cost of an entry ticket
• inputs the estimated number of students taking part, this must be validated on entry and an
unsuitable entry rejected
• calculates and outputs the recommended cost per student to ensure the trip does not make a
loss.

TASK 2 – Record the students who are going and whether they have paid.

Input and store the names of the students who have asked to go on the trip up to the maximum
number allowed. Input and store whether each student has paid. Enable printouts to be produced to
show students who have not paid and those who have paid.

TASK 3 – Work out final costs.

Not all students will end up going on the trip, for example they might not have paid. Modify the
program so that it gives overall totals for the costs charged and the amount of money collected.
Output whether the school trip has made a profit or loss, or has broken even, and the amount of the
final balance.

© UCLES 2017 0478/21/M/J/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Name two constants you used for Task 1 and state the value of each one.

Constant 1 .........................................................................................................................

Value .................................................................................................................................

Constant 2 .........................................................................................................................

Value .................................................................................................................................
[2]

(ii) Name two arrays you used for Task 2 and state the purpose of each one.

Array 1 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

Array 2 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2017 0478/21/M/J/17 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2017 0478/21/M/J/17
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/21/M/J/17 [Turn over


6

(c) (i) Name and describe one suitable validation check you used for Task 1, and one suitable
validation check for Task 2. Each check MUST be different.

Task 1

Name .................................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Task 2

Name .................................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(ii) For each validation check in part (c)(i), give an example of suitable test data and explain
why you chose the test data.

Test data for (c)(i) Task 1 ..................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Test data for (c)(i) Task 2 ..................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2017 0478/21/M/J/17


7

(d) Explain how your program calculates whether or not you have made a profit (Task 3). Any
programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]
© UCLES 2017 0478/21/M/J/17 [Turn over
8

BLANK PAGE

© UCLES 2017 0478/21/M/J/17


9

Section B

2 This section of program code asks for 50 numbers to be entered. The total and average of the
numbers are calculated.

1 Total = 0
2 Counter = 50
3 PRINT ′When prompted, enter 50 numbers, one at a time′
4 REPEAT
5 PRINT ′Enter a number′
6 INPUT Number
7 Total + Number = Total
8 Number = Number + 1
9 UNTIL Counter = 50
10 Average = Number * Counter
11 PRINT ′The average of the numbers you entered is ′, Average

There are four errors in this code.

State the line number for each error and write the correct code for that line.

Error 1 Line number .............................

Correct code .....................................................................................................................................

Error 2 Line number .............................

Correct code .....................................................................................................................................

Error 3 Line number .............................

Correct code .....................................................................................................................................

Error 4 Line number .............................

Correct code .....................................................................................................................................


[4]

© UCLES 2017 0478/21/M/J/17 [Turn over


10

3 A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will then
output directions to the destination in the form of either a visual map or a list of directions.

A satellite navigation system is an example of a computer system that is made up of sub-systems.


This structure diagram shows some of its sub-systems.

Complete the diagram by filling in the empty boxes.

Satellite navigation system

Input destination

Map List

[2]

4 For each of the four statements in the table, place a tick in the correct column to show whether it
is an example of validation or verification.

Statements Validation Verification


To automatically check the accuracy of a bar code
To check if the data input is sensible
To check if the data input matches the data that has been
supplied
To automatically check that all required data fields have been
completed

[4]

© UCLES 2017 0478/21/M/J/17


11

5 (a) Describe the purpose of each statement in this algorithm.

FOR I 1 TO 300
INPUT Name[I]
NEXT I

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Identify, using pseudocode, another loop structure that the algorithm in part (a) could have
used.

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Write an algorithm, using pseudocode, to input a number between 0 and 100 inclusive. The
algorithm should prompt for the input and output an error message if the number is outside
this range.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/21/M/J/17 [Turn over


12

6 This flowchart inputs a range of temperatures in degrees Fahrenheit.

As each temperature is input, it is compared with the previous highest temperature. If it is higher
than the current highest, it replaces the previous highest temperature and then it is converted to
degrees Celsius.

For ease of calculation, the final step of the Fahrenheit to Celsius conversion has been
approximated as division by 2.

When –1 is entered, the input process stops and the highest temperature (in both Fahrenheit and
Celsius) is output.

START

HighF -100
HighC -100

INPUT TempF

Is TempF No Is TempF No
= -1? > HighF?

Yes Yes

HighF TempF

HighC (TempF-32)/2

OUTPUT 'The highest temperature is, ',


HighF, ' Fahrenheit, ',
HighC, ' Celsius.'

END

© UCLES 2017 0478/21/M/J/17


13

Complete the trace table for the input data:

68, 46, 50, 86, 65, 50, 40, 30, –1

HighF HighC TempF OUTPUT

[5]

© UCLES 2017 0478/21/M/J/17 [Turn over


14

7 A television (TV) store has a database table, TVSTOCK, for its new range of televisions. The table
stores the screen size of each TV, whether it will show 3D, whether the screen is curved or flat,
if the internet is available on the TV, if it has a built-in hard disk drive and the price. Part of the
database table is shown below.

TVID ScreenSize 3D CurvedFlat Internet HDD Price


TV80CVINT 80 YES CV YES YES $7,000.00
TV65CVINT 65 YES CV YES YES $5,000.00
TV60CVINT 60 YES CV YES YES $4,500.00
TV60FTINT 60 YES FT YES YES $4,000.00
TV55CVINT 55 YES CV YES NO $3,000.00
TV55FTINT 55 YES FT YES NO $3,500.00
TV55FTNIN 55 YES FT NO NO $3,000.00
TV50CVINT 50 YES CV YES NO $2,500.00
TV50FTINT 50 YES FT YES NO $2,000.00
TV50FTNIN 50 YES FT NO NO $1,750.00
TV42FTINT 42 YES FT YES NO $1,500.00
TV37FTINT 37 NO FT YES NO $1,200.00
TV20FTNIN 20 NO FT NO NO $800.00
TV15FTNIN 15 NO FT NO NO $400.00

(a) State the type of the field TVID and give a reason for your choice.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

(b) Complete the table with the most appropriate data type for each field.

Field name Data type


ScreenSize
3D
CurvedFlat
Internet
HDD
Price
[3]

© UCLES 2017 0478/21/M/J/17


15

(c) Use the query-by-example grid below to provide a list of all of the curved screen TVs that
have a built-in hard disk drive. Make sure the list only displays the TVID, the price and the
screen size in ascending order of price.

Field:
Table:
Sort:
Show:
Criteria:
or:

[5]

© UCLES 2017 0478/21/M/J/17


16

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.

© UCLES 2017 0478/21/M/J/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 5 4 1 6 1 0 3 0 3 1 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (RW/CGW) 132150/3
© UCLES 2017 [Turn over
2

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

The organiser of a senior citizens’ club arranges outings for the members. For each of these
outings a coach is hired, meals at a restaurant are reserved and tickets for the theatre are booked.
A program is required to work out the costs and provide a printed list showing everyone on the outing.

Write and test a program for the club organiser.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Work out the total cost of the outing.

The organiser finds out how many senior citizens would be interested in the outing. The program for
TASK 1 works out the cost from this information.

Number of people Hire of coach ($) Cost of a meal ($) Cost of a theatre ticket ($)
12–16 150 14.00 21.00
17–26 190 13.50 20.00
27–39 225 13.00 19.00

The minimum number of senior citizens needed for the outing to go ahead is 10; there cannot be
more than 36 senior citizens on the outing. A minimum of two carers must go on the outing, with an
additional carer needed if more than 24 senior citizens go on the outing. Carers do not have to pay
anything for the outing. Work out the total cost and the cost per person for the senior citizens.

TASK 2 – Record who is going on the outing and how much has been paid.

Using your results from TASK 1, record the names of the people on the outing and the amount they
have paid; include the carers on the outing. If there are spare places on the coach then extra people
can be added; they are charged the same price as other senior citizens. Calculate the total amount
of money collected. Print out a list of the people on the outing.

TASK 3 – Identify the break-even point or profit that will be made on the outing.

Show whether the outing has made a profit or has broken even using the estimated cost from TASK 1
and the money collected from TASK 2.

© UCLES 2017 0478/22/M/J/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For a variable that you have used to record information about the cost of the outing in
Task 1, state the name, data type and its use.

Variable name ....................................................................................................................

Data type ............................................................................................................................

Use .....................................................................................................................................
[3]

(ii) State two constants that you could have used for Task 1. Give the value that would be
assigned to each one and explain what it is used for.

Constant 1 name ................................................................................................................

Value 1 ...............................................................................................................................

Use 1 ..................................................................................................................................

Constant 2 name ................................................................................................................

Value 2 ...............................................................................................................................

Use 2 ..................................................................................................................................
[6]

(b) Explain how you would need to change your calculation in Task 1 if each carer were paid
$20.00 for coming on the outing.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2017 0478/22/M/J/17 [Turn over


4

(c) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that Task 1 has been completed. You do not need to produce
the list of people on the outing.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2017 0478/22/M/J/17


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/22/M/J/17 [Turn over


6

(d) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2017 0478/22/M/J/17


7

Section B

2 (a) Write an algorithm to input three different numbers, and then output the largest number. Use
either pseudocode or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.

Test data set 1 ...........................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Test data set 2 ...........................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2017 0478/22/M/J/17 [Turn over


8

3 This flowchart inputs the weight of items in kilograms to be loaded on a trailer. Any item over
25 kilograms is rejected. The trailer can take up to 100 kilograms.

START

TotalWeight 0
Reject 0

INPUT Weight

Yes
Is Weight
Reject Reject + 1
˃ 25?
No

TotalWeight TotalWeight + Weight

No Is
TotalWeight
˃ 100?
Yes

TotalWeight TotalWeight – Weight

OUTPUT 'Weight of items '’


TotalWeight, ' Number of
items rejected ',Reject

END

© UCLES 2017 0478/22/M/J/17


9

Complete the trace table for the input data:

13, 17, 26, 25, 5, 10, 15, 35, 20, 15

Weight Reject TotalWeight OUTPUT

[5]

© UCLES 2017 0478/22/M/J/17 [Turn over


10

4 An algorithm has been written in pseudocode to input 100 numbers and print out the sum.
A REPEAT … UNTIL loop has been used.

Count ← 0
Sum ← 0
REPEAT
INPUT Number
Sum ← Sum + Number
Count ← Count + 1
UNTIL Count > 100
PRINT Sum

(a) Find the error in the pseudocode and suggest a correction.

Error ...........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[2]

(b) Rewrite the correct algorithm using a more suitable loop structure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/22/M/J/17


11

5 A database table, SHEEP, is used to keep a record of the sheep on a farm. Each sheep has a
unique ear tag, EARnnnn; n is a single digit. The farmer keeps a record of the date of birth, the
gender and the current weight of each sheep in kilograms.

(a) Identify the four fields required for the database. Give each field a suitable name and data
type. Provide a sample of data that you could expect to see in the field.

Field 1 name ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

Field 2 name ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

Field 3 name ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

Field 4 name ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................


[8]

(b) State the field that you would choose as the primary key.

...............................................................................................................................................[1]

(c) Using the query-by-example grid below, write a query to identify the ear tags of all male
sheep weighing over 10 kilograms. Only display the ear tags.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2017 0478/22/M/J/17


12

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.

© UCLES 2017 0478/22/M/J/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 0 7 6 7 2 9 6 4 1 4 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 14 printed pages and 2 blank pages.

DC (ST/SW) 143869
© UCLES 2017 [Turn over
2

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 teacher is planning a school trip to a theme park at the end of term. You have been asked to write
a program to work out the cost per student, to record those who are going and whether they have
paid. The maximum number of students who can go on the trip is 45.

Write and test a program for the teacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly.
• All 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 – Work out the cost.

The cost of the trip for each student is a share of the cost of a coach plus the cost of entry to the
theme park. The total cost of the coach will be $550. The entry cost to the park is $30 for each
student. The theme park gives one free ticket for every ten that are bought, which must be taken into
consideration. Set up a program that:

• stores the cost of the coach


• stores the cost of an entry ticket
• inputs the estimated number of students taking part, this must be validated on entry and an
unsuitable entry rejected
• calculates and outputs the recommended cost per student to ensure the trip does not make a
loss.

TASK 2 – Record the students who are going and whether they have paid.

Input and store the names of the students who have asked to go on the trip up to the maximum
number allowed. Input and store whether each student has paid. Enable printouts to be produced to
show students who have not paid and those who have paid.

TASK 3 – Work out final costs.

Not all students will end up going on the trip, for example they might not have paid. Modify the
program so that it gives overall totals for the costs charged and the amount of money collected.
Output whether the school trip has made a profit or loss, or has broken even, and the amount of the
final balance.

© UCLES 2017 0478/23/M/J/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Name two constants you used for Task 1 and state the value of each one.

Constant 1 .........................................................................................................................

Value .................................................................................................................................

Constant 2 .........................................................................................................................

Value .................................................................................................................................
[2]

(ii) Name two arrays you used for Task 2 and state the purpose of each one.

Array 1 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

Array 2 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2017 0478/23/M/J/17 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2017 0478/23/M/J/17
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/23/M/J/17 [Turn over


6

(c) (i) Name and describe one suitable validation check you used for Task 1, and one suitable
validation check for Task 2. Each check MUST be different.

Task 1

Name .................................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Task 2

Name .................................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(ii) For each validation check in part (c)(i), give an example of suitable test data and explain
why you chose the test data.

Test data for (c)(i) Task 1 ..................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Test data for (c)(i) Task 2 ..................................................................................................

Reason for choice .............................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2017 0478/23/M/J/17


7

(d) Explain how your program calculates whether or not you have made a profit (Task 3). Any
programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]
© UCLES 2017 0478/23/M/J/17 [Turn over
8

BLANK PAGE

© UCLES 2017 0478/23/M/J/17


9

Section B

2 This section of program code asks for 50 numbers to be entered. The total and average of the
numbers are calculated.

1 Total = 0
2 Counter = 50
3 PRINT ′When prompted, enter 50 numbers, one at a time′
4 REPEAT
5 PRINT ′Enter a number′
6 INPUT Number
7 Total + Number = Total
8 Number = Number + 1
9 UNTIL Counter = 50
10 Average = Number * Counter
11 PRINT ′The average of the numbers you entered is ′, Average

There are four errors in this code.

State the line number for each error and write the correct code for that line.

Error 1 Line number .............................

Correct code .....................................................................................................................................

Error 2 Line number .............................

Correct code .....................................................................................................................................

Error 3 Line number .............................

Correct code .....................................................................................................................................

Error 4 Line number .............................

Correct code .....................................................................................................................................


[4]

© UCLES 2017 0478/23/M/J/17 [Turn over


10

3 A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will then
output directions to the destination in the form of either a visual map or a list of directions.

A satellite navigation system is an example of a computer system that is made up of sub-systems.


This structure diagram shows some of its sub-systems.

Complete the diagram by filling in the empty boxes.

Satellite navigation system

Input destination

Map List

[2]

4 For each of the four statements in the table, place a tick in the correct column to show whether it
is an example of validation or verification.

Statements Validation Verification


To automatically check the accuracy of a bar code
To check if the data input is sensible
To check if the data input matches the data that has been
supplied
To automatically check that all required data fields have been
completed

[4]

© UCLES 2017 0478/23/M/J/17


11

5 (a) Describe the purpose of each statement in this algorithm.

FOR I 1 TO 300
INPUT Name[I]
NEXT I

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Identify, using pseudocode, another loop structure that the algorithm in part (a) could have
used.

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Write an algorithm, using pseudocode, to input a number between 0 and 100 inclusive. The
algorithm should prompt for the input and output an error message if the number is outside
this range.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/23/M/J/17 [Turn over


12

6 This flowchart inputs a range of temperatures in degrees Fahrenheit.

As each temperature is input, it is compared with the previous highest temperature. If it is higher
than the current highest, it replaces the previous highest temperature and then it is converted to
degrees Celsius.

For ease of calculation, the final step of the Fahrenheit to Celsius conversion has been
approximated as division by 2.

When –1 is entered, the input process stops and the highest temperature (in both Fahrenheit and
Celsius) is output.

START

HighF -100
HighC -100

INPUT TempF

Is TempF No Is TempF No
= -1? > HighF?

Yes Yes

HighF TempF

HighC (TempF-32)/2

OUTPUT 'The highest temperature is, ',


HighF, ' Fahrenheit, ',
HighC, ' Celsius.'

END

© UCLES 2017 0478/23/M/J/17


13

Complete the trace table for the input data:

68, 46, 50, 86, 65, 50, 40, 30, –1

HighF HighC TempF OUTPUT

[5]

© UCLES 2017 0478/23/M/J/17 [Turn over


14

7 A television (TV) store has a database table, TVSTOCK, for its new range of televisions. The table
stores the screen size of each TV, whether it will show 3D, whether the screen is curved or flat,
if the internet is available on the TV, if it has a built-in hard disk drive and the price. Part of the
database table is shown below.

TVID ScreenSize 3D CurvedFlat Internet HDD Price


TV80CVINT 80 YES CV YES YES $7,000.00
TV65CVINT 65 YES CV YES YES $5,000.00
TV60CVINT 60 YES CV YES YES $4,500.00
TV60FTINT 60 YES FT YES YES $4,000.00
TV55CVINT 55 YES CV YES NO $3,000.00
TV55FTINT 55 YES FT YES NO $3,500.00
TV55FTNIN 55 YES FT NO NO $3,000.00
TV50CVINT 50 YES CV YES NO $2,500.00
TV50FTINT 50 YES FT YES NO $2,000.00
TV50FTNIN 50 YES FT NO NO $1,750.00
TV42FTINT 42 YES FT YES NO $1,500.00
TV37FTINT 37 NO FT YES NO $1,200.00
TV20FTNIN 20 NO FT NO NO $800.00
TV15FTNIN 15 NO FT NO NO $400.00

(a) State the type of the field TVID and give a reason for your choice.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

(b) Complete the table with the most appropriate data type for each field.

Field name Data type


ScreenSize
3D
CurvedFlat
Internet
HDD
Price
[3]

© UCLES 2017 0478/23/M/J/17


15

(c) Use the query-by-example grid below to provide a list of all of the curved screen TVs that
have a built-in hard disk drive. Make sure the list only displays the TVID, the price and the
screen size in ascending order of price.

Field:
Table:
Sort:
Show:
Criteria:
or:

[5]

© UCLES 2017 0478/23/M/J/17


16

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.

© UCLES 2017 0478/23/M/J/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 9 7 7 7 3 1 5 9 7 3 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 12 printed pages.

DC (CW/SW) 131978/2
© UCLES 2017 [Turn over
2

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 small airfield operates a flying club where people can take a short flight to see if they would like
flying lessons. The owner of the airfield has asked you to write a program to organise the flight
bookings. The airfield operates three different planes and offers either a 30 minute or a 60 minute
flight.

The following table shows the tariff:

Length of Flight 2 Seater Plane 4 Seater Plane Historic Plane


30 minutes $100 $120 $300
60 minutes $150 $200 $500

After each flight, 30 minutes must be allowed for refuelling and safety checks before the next flight
can take off. All planes offer both 30 minute and 60 minute flights, but, for the purpose of this activity,
they will not be mixed on a given day, e.g. the 2 seater will offer 30 minute flights ONLY on one day
and 60 minute flights ONLY on another day.

Write and test a program for the owner of the airfield.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Work out the maximum income.


Assume that the flights take place between 08:00 and 18:00. Write a program that will work out the
maximum income that can be generated by each plane in a day for each type of flight. The program
should allow you to:

• input the type of plane


• input the length of flight
• calculate the maximum number of flights in a day
• output the total possible income per day for the choice of plane and length of flight

TASK 2 – Record bookings.


Write a program to store bookings for each plane and to allow you to find which planes are available
at a given time slot during the day. The program should calculate the actual number of flights taken
by each plane in that day.

TASK 3 – Work out income.


Modify TASK 2 so that it will calculate the total amount of money taken in a day for each plane, as
well as the overall daily total for all three planes, and output the results.

© UCLES 2017 0478/21/O/N/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare suitable arrays for each of the planes to store time slots booked.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) Name one variable and one constant you used for Task 1 and state the purpose of each
one.

Variable .............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

Constant ............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2017 0478/21/O/N/17 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2017 0478/21/O/N/17
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/21/O/N/17 [Turn over


6

(c) Describe how you could validate and test the inputs for Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) Explain how your program checks and displays whether any of the planes are available at a
given time of the day (Task 2). Any programming statements used must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2017 0478/21/O/N/17


7

Section B

2 This section of program code asks for 80 numbers between 100 and 1000 to be entered. It checks
that the numbers are in the correct range, and stores them in an array. It counts how many of the
numbers are larger than 500 and then outputs the result when the program is finished.

1 Count = 0
2 FOR Index = 1 TO 80
3 INPUT 'Enter a number between 100 and 1000', Number
4 WHILE Number = 99 AND Number = 1001
5 INPUT 'This is incorrect, please try again', Number
6 ENDWHILE
7 Num[80] = Number
8 IF Number > 500 THEN Count = Count + 1
9 UNTIL Index = 80
10 PRINT Index
11 PRINT ' numbers were larger than 500'

There are four lines of code that contain errors.

State the line number for each error and write the correct code for that line.

Error 1 Line Number .............................

Correct Code ....................................................................................................................................

Error 2 Line Number .............................

Correct Code ....................................................................................................................................

Error 3 Line Number .............................

Correct Code ....................................................................................................................................

Error 4 Line Number .............................

Correct Code ....................................................................................................................................


[4]

© UCLES 2017 0478/21/O/N/17 [Turn over


8

3 (a) Explain the difference between a validation check and a verification check.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Describe, using an example, how data could be verified on data entry.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Explain what is meant by the term library routine.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

4 (a) Four pseudocode descriptions and five pseudocode statements are shown. Draw one line to
link each pseudocode description to the correct pseudocode statement. Not all pseudocode
statements will be used.

Pseudocode description Pseudocode statement

A loop that will iterate at least


once.
FOR…TO…NEXT

A conditional statement to deal IF…THEN…ELSE…ENDIF


with many possible outcomes.

WHILE…DO…ENDWHILE
A loop that will iterate a set
number of times. CASE…OF…OTHERWISE…ENDCASE

A conditional statement with REPEAT…UNTIL


different outcomes for true
and false.

[4]

© UCLES 2017 0478/21/O/N/17


9

(b) Write an algorithm in pseudocode, using a single loop, to print 50 names that have been
stored in an array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/21/O/N/17 [Turn over


10

5 The flowchart below represents a program routine.

START

Flag 0
Count 1

Is Name[Count] Yes
> Name[Count + 1]? Temp Name[Count]

No Name[Count] Name[Count + 1]

Name[Count + 1] Temp

Flag 1

Count Count + 1

No Is Count
= 4?

Yes

No Is Flag
= 0?

Yes

END

© UCLES 2017 0478/21/O/N/17


11

(a) The array used in the flowchart contains the following data:

Name[1] Name[2] Name[3] Name[4]


Jamal Amir Eve Tara

Complete the trace table using the data given in the array.

Flag Count Name[1] Name[2] Name[3] Name[4] Temp


Jamal Amir Eve Tara

[5]

(b) Describe what the algorithm represented by the flowchart is doing.

...................................................................................................................................................

...............................................................................................................................................[2]

Question 6 begins on Page 12.

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.

© UCLES 2017 0478/21/O/N/17 [Turn over


12

6 A wildlife park has a database table, called LIVESTOCK, to classify and record its animal species.
Part of the database table is shown.

Species Classification Diet Legs


Giraffe Mammal Herbivore 4
Elephant Mammal Herbivore 4
Crocodile Reptile Carnivore 4
Ostrich Bird Omnivore 2
Gorilla Mammal Herbivore 2
Bear Mammal Omnivore 4
Rhinoceros Mammal Herbivore 4
Hippopotamus Mammal Herbivore 4
Flamingo Bird Omnivore 2
Lion Mammal Carnivore 4
Turtle Reptile Omnivore 4
Penguin Bird Carnivore 2

(a) Suggest another appropriate field that could be added to this database by stating its name
and data type. State its purpose and give an example of the data it could contain.

Field name ................................................................................................................................

Data Type .................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

Example of data ........................................................................................................................


[2]

(b) Use the query-by-example grid below to provide a list of all four legged mammals that are
herbivores, sorted alphabetically by species, with only the species displayed.

Field:
Table:
Sort:
Show:
Criteria:
or:

[4]

© UCLES 2017 0478/21/O/N/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 3 7 8 1 9 8 2 0 1 9 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 10 printed pages and 2 blank pages.

DC (CW/FD) 132152/3
© UCLES 2017 [Turn over
2

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

The owner of a river boat hire company wants to calculate the daily profits from hiring out 10 rowing
boats on the river. Boats are numbered 1 to 10. Boats can be hired for use between 10:00 and 17:00
every day.

Write and test a program for the owner.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – calculate the money taken in a day for one boat.

The cost of hiring a boat is $20 for one hour or $12 for half an hour. When a boat is hired the payment
is added to the money taken for the day. The running total of hours hired that day is updated and the
time when the boat must be returned is stored. At the end of the day the money taken and the total
hours hired is output.
No boat can be hired before 10:00 or returned after 17:00.

TASK 2 – find the next boat available.

Extend TASK 1 to work for all 10 rowing boats. Use the data stored for each boat to find out how
many boats are available for hire at the current time. If no boats are available show the earliest time
that a boat will be available for hire.

TASK 3 – calculate the money taken for all the boats at the end of the day.

At the end of the day use the data stored for each boat to calculate the total amount of money taken
and the total number of hours boats were hired that day. Find out how many boats were not used
that day and which boat was used the most. Provide a report for the owner to show this information.

© UCLES 2017 0478/22/O/N/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) For one variable that you have used to record the information about a single boat in
Task 1, state the name, data type and its use.

Variable name ...................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................
[3]

(ii) State one constant and its value that you could have used for Task 1.

Constant name ..................................................................................................................

Value .................................................................................................................................
[2]

(b) Give two different validation checks you could have used for data entry in Task 1. For each
check explain why it could be used and provide a set of data for testing.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

Reason for choice .....................................................................................................................

...................................................................................................................................................

Set of test data .........................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................

Reason for choice .....................................................................................................................

...................................................................................................................................................

Set of test data .........................................................................................................................

...................................................................................................................................................
[6]

© UCLES 2017 0478/22/O/N/17 [Turn over


4

(c) Write an algorithm to complete Task 3, using either pseudocode, programming statements
or a flowchart. You may assume Task 2 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]
© UCLES 2017 0478/22/O/N/17
5

(d) Explain how your program finds out how many boats are available for hire (Task 2).
Any programming statements used must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]
© UCLES 2017 0478/22/O/N/17 [Turn over
6

Section B

2 Write an algorithm using either pseudocode or a flowchart, to:

• input a positive integer


• use this value to set up how many other numbers are to be input
• input these numbers
• calculate and output the total and the average of these numbers.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[6]

© UCLES 2017 0478/22/O/N/17


7

3 The following diagram shows four data structures and four descriptions.

Draw a line to connect each data structure to the correct description.

Data structure Description

Constant A collection of related data

A value that can change whilst a


Array
program is running

A value that never changes whilst a


Table
program is running

A series of elements of the same


Variable
data type
[3]

4 IF … THEN … ELSE … ENDIF is one type of conditional statement used when writing
pseudocode.

Identify and describe another type of conditional statement that you could use when writing
pseudocode. Give a reason why you would use this type of conditional statement.

Conditional statement ......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2017 0478/22/O/N/17 [Turn over


8

5 (a) This flowchart checks a batch of 10 rice sacks for weight. Sacks should weigh 50 kilograms
each. Sacks weighing over 50.5 kilograms or less than 49.5 kilograms are rejected. The
number of sacks accepted and the number of sacks rejected is output.

START

Accept 0
Reject 0
Count 0

Is Count Yes
= 10?
OUTPUT
Accept Accept + 1 Accept,
No
Reject

Count Count + 1
END

INPUT
Sack

Is Sack Yes Reject Reject + 1


< 49.5?

No

Is Sack
No > 50.5? Yes

© UCLES 2017 0478/22/O/N/17


9

Complete the trace table for the input data:

50.4, 50.3, 49.1, 50.3, 50.0, 49.5, 50.2, 50.3, 50.5, 50.6

Accept Reject Count Sack OUTPUT

[5]

(b) The size of the batch has increased to 50 sacks. It has been decided to only reject sacks that
are underweight.

State the changes that need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2017 0478/22/O/N/17 [Turn over


10

6 A database table, TRAIN, is to be set up for a railway company to keep a record of the engines
available for use. Each engine has a unique number made up of 5 digits, nnnnn. The engines
are classified as freight (F) or passenger (P) together with a power classification that is a whole
number between 0 and 9, for example F8. The railway company keeps a record of the date of the
last service for each engine.

(a) Identify the three fields required for the database. Give each field a suitable name and data
type. Provide a sample of data that you could expect to see in the field.

Field 1 Name ............................................................................................................................

Data type ..................................................................................................................................

Data sample .............................................................................................................................

Field 2 Name ............................................................................................................................

Data type ..................................................................................................................................

Data sample .............................................................................................................................

Field 3 Name ............................................................................................................................

Data type ..................................................................................................................................

Data sample .........................................................................................................................[6]

(b) State the field that you should choose as the primary key.

...............................................................................................................................................[1]

(c) Using the query-by-example grid below, write a query to identify all passenger engines that
have not been serviced in the past 12 months. Only display the engine numbers.

Field:
Table:
Sort:
Show:
Criteria:
or:

[3]

© UCLES 2017 0478/22/O/N/17


11

BLANK PAGE

© UCLES 2017 0478/22/O/N/17


12

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.

© UCLES 2017 0478/22/O/N/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 0 4 9 5 1 0 2 8 2 8 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2017
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 12 printed pages.

DC (LK) 150377
© UCLES 2017 [Turn over
2

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 small airfield operates a flying club where people can take a short flight to see if they would like
flying lessons. The owner of the airfield has asked you to write a program to organise the flight
bookings. The airfield operates three different planes and offers either a 30 minute or a 60 minute
flight.

The following table shows the tariff:

Length of Flight 2 Seater Plane 4 Seater Plane Historic Plane


30 minutes $100 $120 $300
60 minutes $150 $200 $500

After each flight, 30 minutes must be allowed for refuelling and safety checks before the next flight
can take off. All planes offer both 30 minute and 60 minute flights, but, for the purpose of this activity,
they will not be mixed on a given day, e.g. the 2 seater will offer 30 minute flights ONLY on one day
and 60 minute flights ONLY on another day.

Write and test a program for the owner of the airfield.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Work out the maximum income.


Assume that the flights take place between 08:00 and 18:00. Write a program that will work out the
maximum income that can be generated by each plane in a day for each type of flight. The program
should allow you to:

• input the type of plane


• input the length of flight
• calculate the maximum number of flights in a day
• output the total possible income per day for the choice of plane and length of flight

TASK 2 – Record bookings.


Write a program to store bookings for each plane and to allow you to find which planes are available
at a given time slot during the day. The program should calculate the actual number of flights taken
by each plane in that day.

TASK 3 – Work out income.


Modify TASK 2 so that it will calculate the total amount of money taken in a day for each plane, as
well as the overall daily total for all three planes, and output the results.

© UCLES 2017 0478/23/O/N/17


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare suitable arrays for each of the planes to store time slots booked.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) Name one variable and one constant you used for Task 1 and state the purpose of each
one.

Variable .............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

Constant ............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2017 0478/23/O/N/17 [Turn over


4

(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2017 0478/23/O/N/17
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2017 0478/23/O/N/17 [Turn over


6

(c) Describe how you could validate and test the inputs for Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) Explain how your program checks and displays whether any of the planes are available at a
given time of the day (Task 2). Any programming statements used must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2017 0478/23/O/N/17


7

Section B

2 This section of program code asks for 80 numbers between 100 and 1000 to be entered. It checks
that the numbers are in the correct range, and stores them in an array. It counts how many of the
numbers are larger than 500 and then outputs the result when the program is finished.

1 Count = 0
2 FOR Index = 1 TO 80
3 INPUT 'Enter a number between 100 and 1000', Number
4 WHILE Number = 99 AND Number = 1001
5 INPUT 'This is incorrect, please try again', Number
6 ENDWHILE
7 Num[80] = Number
8 IF Number > 500 THEN Count = Count + 1
9 UNTIL Index = 80
10 PRINT Index
11 PRINT ' numbers were larger than 500'

There are four lines of code that contain errors.

State the line number for each error and write the correct code for that line.

Error 1 Line Number .............................

Correct Code ....................................................................................................................................

Error 2 Line Number .............................

Correct Code ....................................................................................................................................

Error 3 Line Number .............................

Correct Code ....................................................................................................................................

Error 4 Line Number .............................

Correct Code ....................................................................................................................................


[4]

© UCLES 2017 0478/23/O/N/17 [Turn over


8

3 (a) Explain the difference between a validation check and a verification check.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Describe, using an example, how data could be verified on data entry.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Explain what is meant by the term library routine.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

4 (a) Four pseudocode descriptions and five pseudocode statements are shown. Draw one line to
link each pseudocode description to the correct pseudocode statement. Not all pseudocode
statements will be used.

Pseudocode description Pseudocode statement

A loop that will iterate at least


once.
FOR…TO…NEXT

A conditional statement to deal IF…THEN…ELSE…ENDIF


with many possible outcomes.

WHILE…DO…ENDWHILE
A loop that will iterate a set
number of times. CASE…OF…OTHERWISE…ENDCASE

A conditional statement with REPEAT…UNTIL


different outcomes for true
and false.

[4]

© UCLES 2017 0478/23/O/N/17


9

(b) Write an algorithm in pseudocode, using a single loop, to print 50 names that have been
stored in an array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2017 0478/23/O/N/17 [Turn over


10

5 The flowchart below represents a program routine.

START

Flag 0
Count 1

Is Name[Count] Yes
> Name[Count + 1]? Temp Name[Count]

No Name[Count] Name[Count + 1]

Name[Count + 1] Temp

Flag 1

Count Count + 1

No Is Count
= 4?

Yes

No Is Flag
= 0?

Yes

END

© UCLES 2017 0478/23/O/N/17


11

(a) The array used in the flowchart contains the following data:

Name[1] Name[2] Name[3] Name[4]


Jamal Amir Eve Tara

Complete the trace table using the data given in the array.

Flag Count Name[1] Name[2] Name[3] Name[4] Temp


Jamal Amir Eve Tara

[5]

(b) Describe what the algorithm represented by the flowchart is doing.

...................................................................................................................................................

...............................................................................................................................................[2]

Question 6 begins on Page 12.

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.

© UCLES 2017 0478/23/O/N/17 [Turn over


12

6 A wildlife park has a database table, called LIVESTOCK, to classify and record its animal species.
Part of the database table is shown.

Species Classification Diet Legs


Giraffe Mammal Herbivore 4
Elephant Mammal Herbivore 4
Crocodile Reptile Carnivore 4
Ostrich Bird Omnivore 2
Gorilla Mammal Herbivore 2
Bear Mammal Omnivore 4
Rhinoceros Mammal Herbivore 4
Hippopotamus Mammal Herbivore 4
Flamingo Bird Omnivore 2
Lion Mammal Carnivore 4
Turtle Reptile Omnivore 4
Penguin Bird Carnivore 2

(a) Suggest another appropriate field that could be added to this database by stating its name
and data type. State its purpose and give an example of the data it could contain.

Field name ................................................................................................................................

Data Type .................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

Example of data ........................................................................................................................


[2]

(b) Use the query-by-example grid below to provide a list of all four legged mammals that are
herbivores, sorted alphabetically by species, with only the species displayed.

Field:
Table:
Sort:
Show:
Criteria:
or:

[4]

© UCLES 2017 0478/23/O/N/17


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 4 2 5 9 7 8 5 4 1 5 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (LK/CGW) 148974/2
© UCLES 2018 [Turn over
2

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

Students in a school are allowed to choose extra subjects each year. Students provide the school
administrator with their names and their subject choices. Places in subject groups are allocated on a
‘first come, first served’ basis. There are two classes of 30 students and they can each choose two
extra subjects from:

• Physics
• Chemistry
• History
• Geography
• Computer Science

The maximum group size for each subject choice is 20 students and the minimum group size is 10
students. If more than 20 students choose a subject then that subject can be split into two groups.
Each subject can have no more than two groups. If less than 10 students choose a subject then it
is not available that year. A program is required to show a summary of the number of students who
have chosen each subject, identify subject group sizes, produce subject group lists and identify
problems.

Write and test a program or programs for the school administrator.

• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Data entry and number of students who have chosen each subject.

The school administrator enters the data for each student. Write a program for TASK 1 to store this
data then calculate and output the number of students who have chosen each subject.

TASK 2 – Output subject group lists and identify problems.

Using your results from TASK 1, allocate students to subject groups. Print out list(s) of student
names for each viable subject group. Identify any subjects that are over or undersubscribed, identify
the students who have been allocated to one subject group only and those who have not been
allocated to any group. Print out this information.

TASK 3 – Identify spare places in subject groups.

Using your results from TASK 2, print out the number of spare places for each subject. Any group
that has fewer than 20 students has spare places. Calculate the total number of spare places and
the total number of unallocated student choices. Show whether the number of spare places available
is enough to cover the unallocated choices.

© UCLES 2018 0478/22/F/M/18


3

1 (a) All identifiers should have meaningful names.

(i) State the name and data structure that you have used to record student names in Task 1.

Name .................................................................................................................................

Data structure ....................................................................................................................


[2]

(ii) State the name of one constant and the name of one variable that you could have used
in your programmed solution.
State the value that would be assigned to the constant. State the data type for the
variable. Explain what each one would be used for in your programmed solution.

Constant name ..................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Variable name ...................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[6]

(b) Explain how you would change your program for Task 2 if the maximum group size for each
subject is increased to 25.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2018 0478/22/F/M/18 [Turn over


4

(c) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2018 0478/22/F/M/18
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2018 0478/22/F/M/18 [Turn over


6

(d) Explain how your program calculates the total number of spare places in Task 3. Any
programming statements shown in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2018 0478/22/F/M/18


7

Section B

2 An algorithm has been written in pseudocode to input some numbers and print out any numbers
that are greater than or equal to 100. The number 999 stops the algorithm.

INPUT Number
WHILE NUMBERS <> 999 DO
IF Number > 100 THEN PRINT Number ENDIF
ENDWHILE
PRINT Number

(a) Find the four errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(b) Show, using pseudocode, how you would change the corrected algorithm to print out any
numbers between 100 and 200 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]
© UCLES 2018 0478/22/F/M/18 [Turn over
8

3 This flowchart inputs the weight in kilograms of a passenger stepping into a lift. The lift can take a
maximum of eight passengers or a maximum weight of 640 kilograms.

START

totalWeight 0
totalNumber 0

INPUT Weight

totalWeight totalWeight + Weight


totalNumber totalNumber + 1

Is
Yes
totalWeight
> 640?

No

No Is
Yes
totalNumber
> 8?

OUTPUT 'Lift
overload, step
out'

END

© UCLES 2018 0478/22/F/M/18


9

Complete the trace table for the passenger input data:

50, 70, 65, 100, 95, 50, 55, 85, 70, 75

Weight totalWeight totalNumber OUTPUT

[4]

© UCLES 2018 0478/22/F/M/18 [Turn over


10

4 A program checks if the weight of a baby is at least 2 kilograms.

Give, with reasons, two different values of test data that could be used for the baby’s weight.
Each reason must be different.

Value 1 .............................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Value 2 .............................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[4]

5 Explain the difference between the programming concepts of sequence and selection. Include
an example of a programming statement for each concept in your explanation.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[4]

© UCLES 2018 0478/22/F/M/18


11

6 A database table, JEWEL, is used to keep a record of jewellery for sale in a shop. Each item of
jewellery can be made of silver, platinum or gold metal. The shop stocks rings, bracelets and
necklaces. The number in stock and the price is also stored.

(a) Identify the four fields required for the database. Give each field a suitable name and data
type. Explain why you chose the data type for each field.

Field 1 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 2 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 3 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................

Field 4 Name .................................................... Data type .....................................................

Explanation ...............................................................................................................................

...................................................................................................................................................
[8]

(b) Explain why none of these fields could be used as a primary key.

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Using the query-by-example grid below, write a query to identify the silver bracelets. Only
display the number in stock and the price.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2018 0478/22/F/M/18


12

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.

© UCLES 2018 0478/22/F/M/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 8 1 9 4 9 2 4 0 9 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NF) 148543/2
© UCLES 2018 [Turn over
2

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 computer shop will build a computer from components to meet a customer’s requirements. For
each request for a computer to be built, an estimate of the cost is produced. The component stock
level is checked; if all the components are in stock, a firm order to build the computer can be placed.
A program is required to work out the cost of the computer, update the stock levels and provide a
daily summary of orders for the shop owner.

Write and test a program or programs for the computer shop owner.

• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Produce an estimate.

Write a program for TASK 1 to calculate the cost of building a computer using these components.

Component Choices Prices in $


Processor p3 / p5 / p7 100 / 120 / 200
RAM 16 GB / 32 GB 75 / 150
Storage 1 TB / 2 TB 50 / 100
Screen 19" / 23" 65 / 120
Case Mini Tower / Midi Tower 40 / 70
USB ports 2 ports / 4 ports 10 / 20

The customer makes a choice for each component and an estimate is produced. The estimate must
show a unique estimate number, the components chosen and the price of each component. The
estimate must also show the total cost of the computer, which is calculated as the sum of the cost of
the components chosen plus 20%.

TASK 2 – Place an order.

Using your estimate from TASK 1, check if the components required are in stock. If all the
components are in stock then update the stock levels. Add the unique estimate number to the list
of order numbers. Add the customer’s details and today’s date to the estimate details to finalise the
order. Print two copies of the order, one for the customer and one for the shop.

TASK 3 – Summarise the day’s orders.

Extend TASK 2 to provide an end of day summary showing the number of orders made, the total
number of each component sold and the value of the orders.
© UCLES 2018 0478/21/M/J/18
3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) You recorded information for the estimate of the cost of building a computer in Task 1.
Give a data structure that you created for Task 1, its name, data type and use.

Data structure ....................................................................................................................

Name .................................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[4]

(ii) Describe the data structures that you have used in Task 2 to record the customer details.
Include sample data in the description.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [4]

(b) Explain how your program for Task 1 produces a unique estimate number.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [2]

© UCLES 2018 0478/21/M/J/18 [Turn over


4

(c) Write an algorithm for part of Task 2 to check that the chosen processor and chosen RAM
are in stock, using either pseudocode, programming statements or a flowchart. Assume that
Task 1 has been completed. Do not check the other components or produce the order.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

© UCLES 2018 0478/21/M/J/18


5

(d) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

© UCLES 2018 0478/21/M/J/18 [Turn over


6

Section B

2 (a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [6]
© UCLES 2018 0478/21/M/J/18
7

(b) Give one change you could make to your algorithm to ensure initial testing is more
manageable.

...................................................................................................................................................

.............................................................................................................................................. [1]

Question 3 starts on page 8.

© UCLES 2018 0478/21/M/J/18 [Turn over


8

3 The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.

FOR Count 1 TO 7
INPUT Number
Digit(Count) Number
NEXT
Sum (Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6)
IF MOD(Sum,10) <> 0
THEN Digit(8) DIV(Sum,10)*10 + 10 - Sum
ELSE Digit(8) 0
ENDIF
OUTPUT "GTIN-8"
FOR Count 1 TO 8
OUTPUT Digit(Count)
NEXT

(a) Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1

Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8) Sum OUTPUT

[5]

© UCLES 2018 0478/21/M/J/18


9

(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [3]

Question 4 starts on page 10.

© UCLES 2018 0478/21/M/J/18 [Turn over


10

4 A programmer has written a routine to check that prices are below $10.00. These values are used
as test data.

10.00 9.99 ten

Explain why each value was chosen.

10.00 ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

9.99 ..................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ten ....................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

5 Explain the difference between the programming concepts of counting and totalling.
Include an example of a programming statement for each concept in your explanation.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..................................................................................................................................................... [4]

© UCLES 2018 0478/21/M/J/18


11

6 A database table, PERFORMANCE, is used to keep a record of the performances at a local


theatre.

Show Number Type Title Date Sold Out


SN091 Comedy An Evening at Home 01 Sept Yes
SN102 Drama Old Places 02 Oct No
SN113 Jazz Acoustic Evening 03 Nov No
SN124 Classical Mozart Evening 04 Dec Yes
SN021 Classical Bach Favourites 01 Feb Yes
SN032 Jazz 30 Years of Jazz 02 Mar Yes
SN043 Comedy Street Night 03 Apr No
SN054 Comedy Hoot 04 May No

(a) State the number of fields and records in the table.

Fields ........................................................................................................................................

Records ....................................................................................................................................
[2]

(b) Give two validation checks that could be performed on the Show Number field.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................
[2]

(c) Using the query-by-example grid, write a query to identify jazz performances that are not sold
out. Only display the date and the title.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2018 0478/21/M/J/18


12

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.

© UCLES 2018 0478/21/M/J/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 7 1 1 5 2 4 6 2 5 3 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NH) 148633/2
© UCLES 2018 [Turn over
2

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 farmer records the milk production of a herd of cows. Every cow has a unique 3-digit identity
code. Each cow can be milked twice a day, seven days a week. The volume of milk from each cow
is recorded in litres correct to one decimal place (yield) every time the cow is milked. The size of the
herd is fixed. At the end of the week the total and the average yield for each cow for that week is
calculated.

The farmer identifies the cow that has produced the most milk that week. The farmer also identifies
any cows that have produced less than 12 litres of milk on four or more days that week.

A program is required to record the yield for each cow every time it is milked, calculate the total
weekly volume of milk for the herd and the average yield per cow in a week. The program must also
identify the cow with the best yield that week and identify any cows with a yield of less than 12 litres
of milk for four or more days that week.

Write and test a program or programs for the farmer.

• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Record the yield.

Write a program for TASK 1 to record the milk yields for a week. The program records and stores the
identity code number and the yield every time a cow is milked.

TASK 2 – Calculate the statistics.

Using your recorded data from TASK 1, calculate and display the total weekly volume of milk for
the herd to the nearest whole litre. Calculate and display the average yield per cow in a week to the
nearest whole litre.

TASK 3 – Identify the most productive cow and cows that are producing a low volume of milk.

Extend TASK 2 to identify and display the identity code number and weekly yield of the cow that has
produced the most milk. Also identify and display the identity code numbers of any cows with a yield
of less than 12 litres of milk for four days or more in the week.

© UCLES 2018 0478/22/M/J/18


3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) State the name, the data type and the use of two variables that you have used in Task 2.

Variable 1 name ................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

Variable 2 name ................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................
[2]

(ii) Describe, with the aid of some sample data, the data structures that you have used to
record the data for the cows in Task 1.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

(b) Explain how your program for Task 1 ensures that each 3-digit identity code is unique.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2018 0478/22/M/J/18 [Turn over


4

(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2018 0478/22/M/J/18


5

(d) (i) Explain how your program for Task 3 finds the cows with a daily yield of less than
12 litres of milk for four days or more in the week. Any programming statements used in
your answer must be fully explained.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

(ii) Explain how you would extend your program for Task 3 to store the identity code
number(s) of those cows with a yield of less than 12 litres of milk for four days or more in
the week.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

© UCLES 2018 0478/22/M/J/18 [Turn over


6

Section B

2 (a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends
and the count of positive numbers is output.

[6]
© UCLES 2018 0478/22/M/J/18
7

(b) Explain the changes you will make to your algorithm to also count the negative numbers.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

Question 3 starts on Page 8.

© UCLES 2018 0478/22/M/J/18 [Turn over


8

3 This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.

INPUT Number1, Number2, Sign


WHILE Number1 <> 0
IF Sign = '+' THEN Answer Number1 + Number2 ENDIF
IF Sign = '-' THEN Answer Number1 - Number2 ENDIF
IF Sign = '*' THEN Answer Number1 * Number2 ENDIF
IF Sign = '/' THEN Answer Number1 / Number2 ENDIF
IF Sign <> '/' AND Sign <> '*' AND Sign <> '-' AND Sign <> '+'
THEN Answer 0
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE

(a) Complete the trace table for the input data:


*
5, 7, +, 6, 2, –, 4, 3, , 7, 8, ?, 0, 0, /

Number1 Number2 Sign Answer OUTPUT

[3]

(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2018 0478/22/M/J/18


9

4 A programmer has written a routine to store the name, email address and password of a contributor
to a website’s discussion group.

(a) The programmer has chosen to verify the name, email address and password.

Explain why verification was chosen and describe how the programmer would verify this data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(b) The programmer has also decided to validate the email address and the password.

Describe validation checks that could be used.

Email address ............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Password ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 0478/22/M/J/18 [Turn over


10

5 A program checks that the weight of a basket of fruit is over 1.00 kilograms and under
1.10 kilograms. Weights are recorded to an accuracy of two decimal places and any weight not in
this form has already been rejected.

Give three weights as test data and for each weight state a reason for choosing it. All your reasons
must be different.

Weight 1 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 2 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................

Weight 3 ............................................................................................................................................

Reason ..............................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 0478/22/M/J/18


11

6 A database table, TREES, is used to keep a record of the trees in a park. Each tree is given a
unique number and is examined to see if it is at risk of dying. There are over 900 trees; part of the
database table is shown.

Tree Number Type Map Position Age in Years At Risk


TN091 Acacia A7 250 Y
TN172 Olive C5 110 N
TN913 Cedar B9 8 N
TN824 Banyan A3 50 Y
TN021 Pine D5 560 Y
TN532 Teak C8 76 Y
TN043 Yew B1 340 N
TN354 Spruce D4 65 N
TN731 Elm B10 22 Y
TN869 Oak C9 13 N
TN954 Pine E11 3 N

(a) State the number of fields in the table.

...............................................................................................................................................[1]

(b) The tree numbering system uses TN followed by three digits. The numbering system will not
work if there are over 1000 trees.
Describe, with the aid of an example, how you could change the tree numbering system to
allow for over 1000 trees. Existing tree numbers must not be changed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Using the query-by-example grid, write a query to identify at risk trees over 100 years old.
Display only the type and the position on the map.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
© UCLES 2018 0478/22/M/J/18
12

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.

© UCLES 2018 0478/22/M/J/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 0 5 7 4 8 2 1 2 1 9 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NH/FC) 148635/3
© UCLES 2018 [Turn over
2

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 car park has space for 100 cars and a barrier entrance and exit system. There is a display at the
entrance to show how many spaces are empty. Cars are issued a ticket with a unique number on entry
and the time of issue is stored. The car park charges $1.50 per hour and the fee is paid at a machine
before leaving the car park. At the machine, the ticket number and departure time are entered; the fee is
calculated by the machine and the amount due is paid by the ticket holder. Cars cannot stay overnight; the
system is reset at midnight.

Write and test a program or programs for the car park manager.
• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Operating the car park.

The system is reset at midnight every day.


Set up a system using arrays and with suitable prompts that will carry out the following as cars enter or
leave the car park:

On Entry:
• display the number of empty car park spaces
• issue the next available ticket number
• store the current time and the ticket number
• display the updated number of empty car park spaces.

On Exit:
• input a ticket number and departure time
• output the amount of time the car stayed at the car park
• delete the ticket number from the array
• display the updated number of empty car park spaces.

TASK 2 – Working out the cost and daily takings.

Amend the program so that it will calculate the amount to be paid using a charge of $1.50 per hour, or
part of an hour (i.e. any amount of time into the next hour is charged for a whole hour). The amount to be
paid is displayed and is added to a running total for the day, before the ticket number is deleted from the
array. At the end of the day, the following information is displayed:
• total daily takings
• number of cars that have used the car park
• average charge per car
• average length of stay per car.
TASK 3 – Introducing parking restrictions.
The car park manager decides to restrict the length of stay to a maximum of eight hours, and will charge
an extra $100 if a car overstays. Modify your program to implement this change and ensure the driver is
aware of this extra charge. Output the number of cars that have overstayed in a day.
© UCLES 2018 0478/23/M/J/18
3

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) State the name, data type and use of two arrays you created for Task 1.

Array 1 name .....................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Array 2 name .....................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[4]

(ii) State the name, value and use of two constants you could have created for Task 3.

Constant 1 name ................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Constant 2 name ................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2018 0478/23/M/J/18 [Turn over


4

(b) Write an algorithm to perform the set up and ‘On Entry’ part of Task 1, using either pseudocode,
programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

© UCLES 2018 0478/23/M/J/18


5

(c) Explain how your program calculates if a car has overstayed the permitted parking time and
how the charge is calculated and output (part of Task 3). Any programming statements you
use in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) One of the inputs required ‘On Exit’ in Task 1 is ticket number. State two items of suitable test
data you could use to test your input validation and state why you chose them.

Test data 1 ................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Test data 2 ................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 0478/23/M/J/18 [Turn over


6

Section B

2 Describe, using an example, the purpose of the following checks during data entry.

(a) Validation check

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) Verification check

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

3 This section of program code reads the contents of the array, totals the numbers and prints out the
sum and average of the numbers. Assume the array is full.

Complete the four missing items by writing them in the spaces provided in this code.

1 Numbers[1:30]

2 Total = 0

3 .............................................. = 0

4 FOR Count = 1 TO .........................................................

5 Number = Numbers[Count]

6 Total = ......................................................... + Number

7 Counter = Counter + 1

8 .................................................................................................. Count

9 PRINT ′The sum of the numbers you entered is ′, Number

10 PRINT ′The average of the numbers you entered is ′, Number / Counter


[4]

© UCLES 2018 0478/23/M/J/18


7

4 An algorithm is written in pseudocode:

INPUT Number
IF Number > 100
THEN OUTPUT ″The number is too large″
ELSE OUTPUT ″The number is acceptable″
ENDIF

(a) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(b) (i) The algorithm only allows one attempt at inputting an acceptable value.

State how you would change the algorithm so that it continues until a suitable input is
supplied.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Re-write the algorithm in full, using pseudocode, to implement your answer to part (b)(i).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

© UCLES 2018 0478/23/M/J/18 [Turn over


8

5 The flowchart allows a set of 10 numbers to be entered; it finds and outputs the largest of these
numbers.

START

Max –1000.00
Counter 0

INPUT Num

Yes Is Num >


Max ?

No
Max Num

Counter Counter + 1

Is Counter Yes
< 10 ?

No

OUTPUT Max

END

© UCLES 2018 0478/23/M/J/18


9

(a) Complete the trace table for the input data:

6.30, 18.62, 50.01, 3.13, 2.05, 50.10, 40.35, 30.69, 0.85, 17.30

Max Counter Num OUTPUT

[3]

(b) Describe two different changes you should make to the flowchart to find the smallest number
instead of the largest number.

Change 1 ...................................................................................................................................

...................................................................................................................................................

Change 2 ...................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2018 0478/23/M/J/18 [Turn over


10

6 A shop that sells copies of movies to the public has set up a new database table called 2018MOV
to store some new releases. Part of this table is given, showing the catalogue number, title, genres
and available formats (Blu-ray, DVD or streaming) of each movie.

CatNo Title Genre 1 Genre 2 Blu-ray DVD Stream


18m01 Battery Rangers Adventure Fantasy Yes No Yes
18m02 Golfwatch Comedy Drama Yes No Yes
18m03 Chair 27 Comedy Drama Yes Yes No
18m04 Wander Woman Action Fantasy Yes No Yes
18m05 Justine League Action Fantasy Yes Yes Yes
18m06 That Horror Thriller Yes Yes No
18m07 Insect Dude Action Fantasy No Yes No
18m08 Dover Beach Action History No Yes No
18m12 Slow 25 Action Thriller No Yes No
18m15 Kongkers Adventure Fantasy No Yes No
18m16 Transducers: The Last Night Action Sci-Fi Yes Yes Yes
18m17 The Pale Tower Fantasy Sci-Fi Yes Yes No
18m19 Bea and the Bute Fantasy Romance Yes Yes Yes
18m21 The Daddy Action Fantasy No No Yes
18m22 Planet Wars: Episode X Sci-Fi Action Yes No Yes
18m23 Guardians of the Milky Way Action Sci-Fi Yes Yes Yes
18m26 Odin Horror Sci-Fi No Yes Yes
18m27 That Fantasy Sci-Fi No No Yes
18m30 Underneath Action Horror Yes No No
18m31 Debatable Me Animation Action Yes Yes No

(a) State the number of records in this part of the table.

...............................................................................................................................................[1]

(b) (i) Give the name of the field that should be used for the primary key.

.......................................................................................................................................[1]

(ii) State the reason for choosing this field for the primary key.

...........................................................................................................................................

.......................................................................................................................................[1]

© UCLES 2018 0478/23/M/J/18


11

(c) Complete the table to show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.

Field Data type


CatNo
Title
Genre 1
Stream
[2]

(d) List the output that would be given by this query-by-example.

Field: CatNo Title Genre 1 Blu-ray DVD Stream


Table: 2018MOV 2018MOV 2018MOV 2018MOV 2018MOV 2018MOV
Sort:
Show: 3 3 3 3 3
Criteria: =“Comedy”
or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(e) Using the query-by-example grid, write a query to identify all the movies that are categorised
as Sci-Fi and available to stream. Only display the catalogue number and title of the film, with
the titles listed in alphabetical order.

Field:
Table:
Sort:
Show:
Criteria:
or:

[4]

© UCLES 2018 0478/23/M/J/18


12

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.

© UCLES 2018 0478/23/M/J/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 6 8 7 9 7 0 8 2 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 14 printed pages and 2 blank pages.

DC (SR/SG) 150262/3
© UCLES 2018 [Turn over
2

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

You are working at a local take-away shop and you have decided to write a program to track daily
takings and profit. Here is the menu:

Menu item Price


French fries $2.00
1/4 pound burger $5.00
1/4 pound cheeseburger $5.55
1/2 pound burger $7.00
1/2 pound cheeseburger $7.50
Medium pizza $9.00
Medium pizza with extra toppings $11.00
Large pizza $12.00
Large pizza with extra toppings $14.50
Garlic bread $4.50

Write and test a program or programs.


• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 menu.


Set up a series of arrays to store the menu items and the prices, using the data supplied in the
menu. Devise an item code for each menu item and store these in another array. Output a new
menu including the item codes so that customers can place an order using the item codes.

TASK 2 – Placing an order.


Extend the program so that when a customer places their order from the menu you enter each item
code and the quantity. When the order is completely entered, a unique order code is generated.
Display the order ensuring that the unique order code, menu items and quantities are shown, along
with the item prices and the total cost of the order. Set up arrays for the day to store the unique order
code and the total cost of each order.

TASK 3 – Calculating daily takings and profit.


10% of the takings are profit. Extend the program to display the total daily takings and profit.
Modify your program to allow you to enter the percentage of the takings that are profit. Output the
total daily takings, the profit and the percentage used in the calculation.
© UCLES 2018 0478/21/O/N/18
3

1 (a) All arrays, variables, constants and other identifiers should have meaningful names.

(i) State the name, data type and use of two arrays you created for Task 1.

Array 1 name ......................................................................................................................

Data type ............................................................................................................................

Use .....................................................................................................................................

...........................................................................................................................................

Array 2 name ......................................................................................................................

Data type ............................................................................................................................

Use .....................................................................................................................................

...........................................................................................................................................
[4]

(ii) State the name, data type and use of two variables you have created for Task 2.

Variable 1 name .................................................................................................................

Data type ............................................................................................................................

Use .....................................................................................................................................

...........................................................................................................................................

Variable 2 name .................................................................................................................

Data type ............................................................................................................................

Use .....................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2018 0478/21/O/N/18 [Turn over


4

(b) Write an algorithm to enter each item code and quantity. Then when the order is completely
entered, generate a unique order code (part of Task 2), using either pseudocode,
programming statements or a flowchart. You should assume that Task 1 has already been
completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2018 0478/21/O/N/18
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]
© UCLES 2018 0478/21/O/N/18 [Turn over
6

(c) Explain how your program calculates the profit using your input (last part of Task 3) with
variable profit percentage and outputs the results. Any programming statements you use in
your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

© UCLES 2018 0478/21/O/N/18


7

(d) State three items of test data you could use in Task 3 to test the input of the percentage profit
value and explain why you chose them.

Your reasons must be different for each item of test data.

Test data 1 .................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................

Test data 2 .................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................

Test data 3 .................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2018 0478/21/O/N/18 [Turn over


8

Section B

2 Six terms associated with programming and six descriptions are listed.

Draw a line to link each term with its most appropriate description.

Term Description

Pre-written code to include in


Top-down design your own program to carry out
a common task.

Shows the steps representing


Structure diagram an algorithm using various
shapes of boxes.

Shows the hierarchy of the


Flowchart different components which
make up a system.

Shows the values of variables


Pseudocode as you manually test your
program.

Breaks down a system into


Library routine
successively smaller pieces.

Describes a program using a


Trace table
simplified high-level notation.

[5]

© UCLES 2018 0478/21/O/N/18


9

3 Describe, giving a different example for each, the purpose of these validation checks used in
programming.

Range check ....................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Length check ....................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Type check .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2018 0478/21/O/N/18 [Turn over


10

4 An algorithm is written in pseudocode:

Total 0
FOR Count 1 TO 50
INPUT Num
Total Total + Num
NEXT Count
OUTPUT Total

(a) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(b) Re-write the algorithm in pseudocode using a different type of loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Describe how you could modify the original algorithm shown at the start of question 4, to
allow any number of inputs.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2018 0478/21/O/N/18


11

Question 5 starts on page 12.

© UCLES 2018 0478/21/O/N/18 [Turn over


12

5 The flowchart performs a mathematical process on a number input called TestNum

DIV is used to represent integer division e.g. 7 DIV 3 = 2

START

Flag True

INPUT
TestNum

Num TestNum – 1

Yes Is Num = No
1?

Num Num – 1

Yes Is TestNum / No
Flag False Num = TestNum
DIV Num ?

Is Flag = Yes
True ?

No

OUTPUT
TestNum

END

© UCLES 2018 0478/21/O/N/18


13

(a) Complete the trace table for the input data: 7

Flag TestNum Num OUTPUT

[2]

(b) Complete the trace table for the input data: 6

Flag TestNum Num OUTPUT

[2]

(c) State the purpose of the algorithm in the flowchart.

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2018 0478/21/O/N/18 [Turn over


14

6 The database table, PCSTOCK, is a part of the database in an electronics shop, showing some of
the desktop (DT), tablet (TB) and laptop (LT) computers they have in stock.

PCID ScreenSize RAM Type HDD(GB) Price


DT303240 30 32 DT 4000 $5000.00
DT303220 30 32 DT 2000 $4500.00
DT301620 30 16 DT 2000 $4000.00
DT231610 23 16 DT 1000 $3000.00
LT191620 19 16 LT 2000 $3000.00
LT171610 17 16 LT 1000 $2500.00
DT230820 23 8 DT 2000 $2000.00
DT190810 19 8 DT 1000 $1500.00
LT190810 19 8 LT 1000 $1500.00
LT170805 17 8 LT 500 $1200.00
DT230420 23 4 DT 2000 $1000.00
DT190410 19 4 DT 1000 $750.00
LT190410 19 4 LT 1000 $950.00
TB100206 10 2 TB 64 $200.00

(a) Complete the table to show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.

Field Data type


PCID
ScreenSize
Type
Price
[2]

(b) Using the query-by-example grid, write a query to identify all the desktop computers with a
hard drive larger than 1000 GB. All fields in the table should be shown, sorted in descending
order by price.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2018 0478/21/O/N/18


15

BLANK PAGE

© UCLES 2018 0478/21/O/N/18


16

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.

© UCLES 2018 0478/21/O/N/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 0 8 2 3 0 1 4 9 5 1 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NF/SG) 150276/4
© UCLES 2018 [Turn over
2

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 junior park run event is held every week on a Saturday morning in a local park over a distance of
two kilometres. Children between the ages of 4 and 14 inclusive can register to take part. Children
register with their name and age. When they register, they are allocated a unique identification
number of four digits; the last digit is a check digit. Once registered a child can take part in junior
park run events for a year.
For each event, the organisers record the time each child takes to run two kilometres. Their time is
stored for every event they complete and the number of runs they have completed is updated by
one. If their time is faster than their personal best (PB) time, their PB time is updated. When a child
has completed 11 runs, they are awarded a half-marathon wristband. When a child has completed
22 runs, they are awarded a full-marathon wristband.
A program is required to update the children’s data, update PB times if necessary, and decide if a
wristband is to be awarded. The program also needs to identify the fastest child at this event for
each of the age ranges: 4 to 6, 7 to 10 and 11 to 14.

Write and test a program or programs for the park run organiser.

• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and be understandable.
• All variables, arrays, constants and other identifiers must have meaningful names.

You will need to complete these three tasks. Each task must be fully tested.

TASK 1 – Registering to take part.

Write a program to set up arrays to store the data for 20 children. On registration, each child must
be allocated a unique identification number of four digits; the last digit is a check digit. The unique
identification number, age in years and name for each child is recorded and stored on registration.
The PB time and the number of runs are initialised to zero and these values stored on registration.
Their PB time is stored as minutes correct to two decimal places.

TASK 2 – Recording the times.

Extend your program to record the unique identification number and to input the start time and finish
time for every child completing the junior park run event. Calculate and store the time each child
took to complete the run. A registered child does not have to compete in each event. Only one time
per child is recorded during an event.

TASK 3 – Updating the children’s data and identifying the fastest child for each age range.

Extend your program to update the number of runs and the PB time if necessary for every child
completing the junior park run event. Check if any half- or full-marathon wristbands need to be
awarded. Output the names and the type of wristbands. Output the names and the times of the
fastest child at this event for each of the age ranges 4 to 6, 7 to 10 and 11 to 14.
© UCLES 2018 0478/22/O/N/18
3

1 (a) All variables, arrays, constants and other identifiers should have meaningful names.

(i) State the name of one variable you have used for Task 3.
Give the data type for the variable. State what it is used for.

Variable name ...................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................
[3]

(ii) Describe the arrays that you have used to store the data for the children in Task 1.
Include the name, data type and its use for each array.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...................................................................................................................................... [5]

(b) Explain how you ensured that each identification number entered in Task 1 was unique and
included a correct check digit.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2018 0478/22/O/N/18 [Turn over


4

(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. You should assume that Task 1 has already been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2018 0478/22/O/N/18
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]
© UCLES 2018 0478/22/O/N/18 [Turn over
6

(d) Explain how your program identifies and outputs the names and times of the fastest runner
for each age range in Task 3. Any programming statements used in your answer must be
fully explained. Do not include the wristband check or PB time update.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [4]

© UCLES 2018 0478/22/O/N/18


7

Section B

2 (a) Write an algorithm, using pseudocode, to input three different numbers, multiply the two
larger numbers together and output the result. Use the variables: Number1, Number2 and
Number3 for your numbers and Answer for your result.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................. [5]

(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.

Test data set 1 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Test data set 2 ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2018 0478/22/O/N/18 [Turn over


8

3 Four programming concepts and four descriptions are shown.


Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description


A subroutine that does not
Library routine
have to return a value.

Structure A standard subroutine that is


diagram available for immediate use.

A subroutine that always


Procedure
returns a value.

An overview of a program or
Function
subroutine.
[3]

4 A programmer wants to test that the readings from 2000 electricity meters are greater than 400
units and less than 900 units. The programmer uses selection and repetition statements as part of
the program.
Explain, using programming statements, how selection and repetition could be used in this
program.

Selection ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Repetition .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2018 0478/22/O/N/18


9

BLANK PAGE

Question 5 starts on page 10.

© UCLES 2018 0478/22/O/N/18 [Turn over


10

5 The flowchart checks the level of chlorine and the depth of water compared to the height of the
swimming pool. Error messages are output if a problem is found.

START

INPUT Height,
Depth, Chlorine

OK True

OUTPUT
Is Depth > Yes
"Water too
Height/2 ? deep"

No
OUTPUT
Is Depth < Yes "Water too
Height/3 ? shallow"

No
OK False

Yes OUTPUT "Too


Is Chlorine much chlorine
>3 ? add more water"
No

OUTPUT "Too
Yes little chlorine
Is Chlorine
<1 ? add more chlorine"
No

No
Is OK = True ?

Yes

OUTPUT "Pool OK
to use"

END

© UCLES 2018 0478/22/O/N/18


11

(a) Complete the trace tables for each set of input data.

Input data: 6, 2.5, 2

Height Depth Chlorine OK OUTPUT

Input data: 4, 3, 1.5

Height Depth Chlorine OK OUTPUT

Input data: 6, 3.5, 4

Height Depth Chlorine OK OUTPUT

[6]

(b) Identify a problem with the algorithm that the flowchart represents.

...................................................................................................................................................

.............................................................................................................................................. [1]

© UCLES 2018 0478/22/O/N/18 [Turn over


12

6 A database table, PORTRAIT, is used to keep a record of the portraits available from a photographic
studio. Each portrait has a unique reference number PICnnn, where n is a single digit, for example
PIC123. The studio keeps a record of the size (for example 20 × 15), the type (black and white or
colour), and the price in dollars.

(a) Complete the table to show the most appropriate data type for each of the fields.

Field Data type

Reference Number

Size

Type

Price in $
[4]

(b) The results from the query-by-example grid should show the reference number, price, type
and size of all portraits under $50. Identify the three errors in the query-by-example grid.

Field: Reference No Price in $ Type Size

Table: PORTRAIT PORTRAIT PORTRAIT PORTRAIT

Sort:

Show:   
Criteria: >50.00

or:

Error 1 .......................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................
[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 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.

© UCLES 2018 0478/22/O/N/18


Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 2 1 4 6 7 9 8 7 3 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2018
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (CE) 150280/3
© UCLES 2018 [Turn over
2

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 holiday park has a number of log cabins that it rents by the week as shown in the table:

Name Capacity Peak Off-peak


Hetty 4 $400.00 $250.00
Poppy 4 $400.00 $250.00
Blue Skies 4 $500.00 $350.00
Bay View 6 $650.00 $500.00
Happy Days 6 $695.00 $550.00
Summer Joy 6 $800.00 $600.00
Walkers’ Rest 8 $950.00 $750.00
Bertie 8 $1050.00 $850.00
Green Forest Lodge 10 $1200.00 $950.00
Coppice Lodge 10 $1500.00 $1150.00

The capacity represents the maximum number of occupants for each log cabin. A program is needed
to record and store bookings. Log cabins can only be booked from weeks labelled on the calendar
as weeks 23 to 39, inclusive. Peak rates operate for weeks 27 to 35, inclusive, and off-peak rates
apply for weeks 23 to 26 and weeks 36 to 39, inclusive.

Write and test a program or programs.


• Your program or programs must include appropriate prompts for the entry of data.
• 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 bookings system.


Write a program, using arrays, to identify each log cabin, its capacity, cost and whether or not it has
been booked for each week. Identify each week by a number ranging from week 23 to 39.

TASK 2 – Taking a booking.


Extend the program to:
• Identify and display which weeks are available for each log cabin, and its capacity.
• Input the log cabin, number of weeks and start week for the booking.
• Generate a unique booking code for the week(s) and log cabin chosen.
• Store the unique booking code in your array
(multiple week bookings will need the booking code stored multiple times).
• Calculate and output the cost of the booking.

TASK 3 – Applying a special offer.


Amend the program to apply a 10% discount to any booking of three weeks or more. Output the
original cost and the discounted cost of the booking.
© UCLES 2018 0478/23/O/N/18
3

1 (a) All arrays, variables, constants and other identifiers should have meaningful names.

(i) State the name, data type and use of three arrays you have created for Task 1.

Array 1 name .....................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Array 2 name .....................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

Array 3 name .....................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[6]

(ii) State the name, data type and use for one variable you used in Task 2.

Variable name ...................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[2]

© UCLES 2018 0478/23/O/N/18 [Turn over


4

(b) Write an algorithm to show how your program finds and displays the weeks available for
each log cabin and its capacity (part of Task 2), using either pseudocode, programming
statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2018 0478/23/O/N/18
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]
© UCLES 2018 0478/23/O/N/18 [Turn over
6

(c) Describe how you could validate the input to identify a log cabin in Task 2. State one valid
and one invalid item of data to test your validation method.

Validation method .....................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Valid test data ...........................................................................................................................

Invalid test data ........................................................................................................................


[4]

(d) Explain how your program performs Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]
© UCLES 2018 0478/23/O/N/18
7

Section B

2 Describe, giving an example for each, the following data types used in programming.

Integer

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................

String

Description ........................................................................................................................................

..........................................................................................................................................................

Example ............................................................................................................................................
[4]

3 Give an example of a pseudocode statement or statements to perform each of the following


functions.

A condition controlled loop ...............................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

A conditional statement ....................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Totalling ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2018 0478/23/O/N/18 [Turn over


8

4 This is a section of program code.

1 Total = 100.00
2 PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4 PRINT ′Enter a height in metres′
5 INPUT Height
6 Total = Total + Height
7 PRINT Total / 30
8 Count = Count + 1
9 NEXT Count

(a) There are three errors in this code.

State the line numbers that contain the errors and describe how to correct each error.

Error 1 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(b) State the purpose of this program.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2018 0478/23/O/N/18


9

5 The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.

Fib 1
Prev2 0
Prev1 1
INPUT Number
IF Number = 0
THEN Fib 0
ENDIF
WHILE Number > 2
Fib Prev2 + Prev1
Prev2 Prev1
Prev1 Fib
Number Number - 1
ENDWHILE
OUTPUT Fib

(a) Complete the trace table for the input data: 7

Fib Prev2 Prev1 Number OUTPUT

[4]

(b) Complete the trace table for the input data: 2

Fib Prev2 Prev1 Number OUTPUT

[2]

© UCLES 2018 0478/23/O/N/18 [Turn over


10

6 An online fruit tree specialist sells fruit trees in various sizes. A database table, TREETAB, shows
the tree type and, for each size, the price and whether they are in stock.

Tree Type Size1 Size1 In Size2 Size2 In Size3 Size3 In


Apple 10.95 Yes 14.95 Yes 29.95 Yes
Apple 12.95 Yes 14.95 Yes 29.95 Yes
Cherry 24.95 No 34.95 No 59.95 Yes
Fig 19.95 Yes 29.95 No 49.95 Yes
Guava 19.95 No 29.95 No 59.95 No
Nectarine 8.50 Yes 11.95 Yes 19.95 Yes
Olive 19.95 No 39.95 Yes 59.95 Yes
Peach 9.25 No 11.95 Yes 19.95 Yes
Pear 10.95 Yes 14.95 Yes 29.95 Yes
Plum 8.95 Yes 11.95 Yes 19.95 Yes
Pomegranate 12.95 No 18.95 Yes 34.95 No
Quince 34.95 Yes 44.95 Yes 84.95 No

(a) State whether any of the fields shown would be suitable as a primary key.

...................................................................................................................................................

Explain your answer .................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the table to show the most appropriate data type for each of the fields based on the
data shown in the table at the start of question 6.

Field Data type


Tree Type
Size3
Size2 In
[3]

© UCLES 2018 0478/23/O/N/18


11

(c) Show the output that would be given by this query-by-example.

Field: Tree Type Size1 Size1 In

Table: TREETAB TREETAB TREETAB

Sort: Descending

Show:   

Criteria: <10.00

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[4]

(d) Using the following query-by-example grid, write a query to identify all types of the fruit trees
that are out of stock for all three sizes. Make sure the type of the tree and the various ‘in
stock’ fields are shown. The trees should be listed in alphabetical order by type.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

© UCLES 2018 0478/23/O/N/18


12

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.

© UCLES 2018 0478/23/O/N/18


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 1 5 5 1 7 2 6 6 4 2 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 14 printed pages and 2 blank pages.

DC (LK/CB) 162269/1
© UCLES 2019 [Turn over
2

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 pizza ordering service allows customers to design their own pizza. There are three sizes: small,
medium and large. A pizza can have a thick or thin base. All pizzas come with tomato and cheese
toppings as standard and there are six additional types of topping available:

• Pepperoni
• Chicken
• Extra cheese
• Mushrooms
• Spinach
• Olives

Pizzas always come with tomato and cheese toppings as standard, and can have up to three
additional toppings. Customers need to be able to design their own pizza and then confirm or
change it. Records are kept showing the number of pizzas sold for each base and size. The number
of sales for each additional topping is also recorded.

Write and test a program or programs for the pizza ordering service.

• Your program or programs must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Design your pizza.

The customer is given choices of size, base and additional toppings (number and type) as stated
above. Only valid choices can be accepted. The customer is asked to confirm their order or alter
their choices or not proceed. If the customer confirms their order they are given a unique order
number.

TASK 2 – Record the choices.

Extend TASK 1 to record totals for the choices made for ordered pizzas only and calculate the total
number of pizzas ordered.

TASK 3 – Find the most and least popular additional pizza toppings.

Using your results from TASK 2, display the most popular and least popular additional toppings as a
percentage of the total number of additional toppings ordered.

© UCLES 2019 0478/22/F/M/19


3

1 (a) All variables, constants and other identifiers should have meaningful names.

State one constant and one variable that you could have used for Task 1. Give the value that
would be assigned to the constant. Give the data type for the variable. Explain what each one
could be used for.

Constant name .........................................................................................................................

Value .........................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Variable name ...........................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[6]

(b) Explain how you would need to change your program for Task 1 if there were three bases to
choose from (thick, thin and extra crispy).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/22/F/M/19 [Turn over


4

(c) (i) Write an algorithm for choosing the additional toppings in Task 1, using either
pseudocode, programming statements or a flowchart. Your algorithm must only include
this part of Task 1.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

© UCLES 2019 0478/22/F/M/19


5

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]
© UCLES 2019 0478/22/F/M/19 [Turn over
6

(ii) Explain how your algorithm in part (c)(i) only allowed valid choices for the additional
pizza toppings.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2019 0478/22/F/M/19


7

(d) Explain how your program completed Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/22/F/M/19 [Turn over


8

Section B

2 (a) An algorithm has been written in pseudocode to input 50 numbers and total only the positive
numbers.

Count 1 ←
Total ←
Count
REPEAT
INPUT Number
IF Number <> 0
THEN
Total ←
Total + Count
ENDIF
Count ←
Count + 1
UNTIL Count < 50
PRINT Total

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(b) Show how you would change the corrected algorithm to only total numbers greater than 0
and less than 20.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/22/F/M/19


9

Question 3 starts on page 10.

© UCLES 2019 0478/22/F/M/19 [Turn over


10

3 This flowchart inputs the type of passenger for a survey: S for Senior, A for Adult, C for Child. All
other values are ignored, apart from Z which ends the process.

START

Senior 0
Adult 0
Child 0

INPUT Type

Is Type = Yes
Senior Senior + 1
"S" ?

No

Is Type = Yes
Adult Adult + 1
"A" ?

No

Is Type = Yes
Child Child + 1
"C" ?

No

No Is Type =
"Z" ?

Yes
OUTPUT "Seniors ", Senior
OUTPUT "Adults ", Adult
OUTPUT "Children ", Child

END

© UCLES 2019 0478/22/F/M/19


11

Complete the trace table for the passenger input data:


S, S, S, A, C, C, C, A, A, A, A, W, S, S, D, C, Z, D, S

Senior Adult Child Type OUTPUT

[5]

© UCLES 2019 0478/22/F/M/19 [Turn over


12

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition

FOR X ← 1 TO 10
SUM ← SUM + 1
NEXT X
WHILE X > 10 DO
SUM ← SUM + 1
X ←X - 1
ENDWHILE
IF X > 10
THEN
SUM ← SUM + 1
X ←X - 1
ENDIF
REPEAT
SUM ← SUM + 1
X ←X - 1
UNTIL X > 10
[4]

© UCLES 2019 0478/22/F/M/19


13

5 A programmer restricts input values to less than 90 and greater than 60.

(a) State whether this is called validation or verification.

...................................................................................................................................................

Name the check that needs to be used.

...................................................................................................................................................
[2]

(b) State three different types of test data the programmer would need to use. Give an example
of each type and the reason that the programmer chose that test data.

Type 1 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Type 2 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Type 3 .......................................................................................................................................

Example ....................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[9]

© UCLES 2019 0478/22/F/M/19 [Turn over


14

6 A database table, BIKETYRES, is used to keep a record of tyres for sale in a cycle shop.
Tyres are categorised by width and diameter in millimetres, whether they have an inner tube and
the type of terrain for which they are designed.

Tyre Code Width Diameter Tube Terrain Stock Level


SLTT 23 700 YES Asphalt 18
MLNT 24 700 NO Asphalt 23
LLNT 28 700 NO Asphalt 19
SLTM 23 700 YES Mixed 22
MLTM 24 700 YES Mixed 14
LLTM 28 700 YES Mixed 12
SLTH 23 700 YES Hard 10
MLTH 24 700 YES Hard 5
LLNH 28 700 NO Hard 7
SLNM 23 700 NO Mixed 12
MLNM 24 700 NO Mixed 22
LLNM 28 700 NO Mixed 18
SSNT 23 650 NO Asphalt 10
MSNT 24 650 NO Asphalt 8
SSTM 23 650 YES Mixed 5
MSNM 24 650 NO Mixed 4

The query-by-example grid below displays the tyre code and the stock level of all 28 mm width
tyres suitable for mixed terrain.

Field: Tyre Code Stock Level Width Terrain


Table: BIKETYRES BIKETYRES BIKETYRES BIKETYRES
Sort:
Show: 3 3
Criteria: = 28 = 'Mixed'
or:

Alter the query to show the tyre code and stock level in ascending order of stock level for all
24 mm asphalt terrain tyres. Write the new query in the following query-by-example grid.

Field:
Table:
Sort:
Show:

Criteria:
or:
[4]
© UCLES 2019 0478/22/F/M/19
15

BLANK PAGE

© UCLES 2019 0478/22/F/M/19


16

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 0478/22/F/M/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 2 5 0 9 2 3 6 3 9 5 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 13 printed pages and 3 blank pages.

DC (SC) 162367/3
© UCLES 2019 [Turn over
2

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
The local high school uses buses to transport students to school. There are six bus routes labelled A to F. You have
conducted a survey to analyse the punctuality statistics of these buses over a four-week period. The data from the
survey are shown in the table:

Punctuality table
Day Bus A Bus B Bus C Bus D Bus E Bus F
Mon1 0 0 2 1 −1 0
Tue1 0 1 0 0 −1 −5
Wed1 0 0 −1 0 −1 −5
Thu1 2 0 −1 0 −2 −5
Fri1 2 1 −2 0 −4 −4
Mon2 4 2 −2 0 −10 −3
Tue2 0 0 −3 0 −2 −5
Wed2 3 0 −1 0 0 0
Thu2 4 0 0 0 0 0
Fri2 −2 0 0 0 0 0
Mon3 −5 1 −2 2 0 0
Tue3 0 0 0 0 1 −2
Wed3 0 0 1 0 2 −3
Thu3 3 0 1 0 −3 1
Fri3 4 2 1 0 1 1
Mon4 −1 0 1 0 1 1
Tue4 8 0 −1 0 3 0
Wed4 1 1 −1 0 −1 0
Thu4 1 0 2 0 0 −2
Fri4 −2 0 −2 0 0 −5
Positive numbers represent minutes early, negative numbers represent minutes late and 0 represents the bus having
been on time.

Write and test a program or programs for the local high school.

• 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 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 data storage.


Using arrays set up a system to enable data for each bus route to be entered covering each day of a four-week
period. It must be possible to enter the data supplied or your own set of data, using suitable prompts as necessary.

Task 2 – Working out the statistics.


Extend your program so that the following statistics for the four-week period may be calculated and output:
• the number of late arrivals for each bus route
• the average number of minutes late for each bus route
• the bus route with the highest number of days on which it was late
• the average number of minutes late for each bus route, using only data from days on which it was late
All the results should be displayed with appropriate annotation.

Task 3 – Checking specific days.


Extend the program as follows:
• Allow the user to input a specific day, for example Fri3, to be used for analysis of data.
• Find and display how many buses were late on this particular day.
• For each late bus, display the route label and how late the bus was on this particular day.

© UCLES 2019 0478/21/M/J/19


3

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

(i) State one array you used for Task 1. State the data type and purpose of this array.

Array ..................................................................................................................................

Data type ...........................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) State one variable you used for Task 2 and one variable you used for Task 3. In each
case, state the data type and purpose of the variable.

Task 2 variable name ........................................................................................................

Data type ...........................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Task 3 variable name ........................................................................................................

Data type ...........................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[6]

© UCLES 2019 0478/21/M/J/19 [Turn over


4

(b) Write an algorithm to show how you calculated and output the number of late arrivals and the
average number of minutes late for each bus route (part of Task 2), using either pseudocode,
programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2019 0478/21/M/J/19


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2019 0478/21/M/J/19 [Turn over
6

(c) Explain how your program uses the input in Task 3 to only find the data for that specific day
(part of Task 3). Any programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2019 0478/21/M/J/19


7

(d) Explain how you would alter your program in Task 1 to allow you to choose the number of
weeks to enter data on bus arrival times.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/21/M/J/19 [Turn over


8

Section B

2 Describe each of the following data types used in programming. In each case, give an example of
a piece of data to illustrate your answer. Each example must be different.

Char

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

String

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Boolean

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

3 (a) Give an example of a conditional statement using pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Describe the purpose of a conditional statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/21/M/J/19


9

Question 4 starts on page 10.

© UCLES 2019 0478/21/M/J/19 [Turn over


10

4 This section of program code may be used as a validation check.

1 PRINT "Input a value between 0 and 100 inclusive"


2 INPUT Value
3 WHILE Value < 0 OR Value > 100
4 PRINT "Invalid value, try again"
5 INPUT Value
6 ENDWHILE
7 PRINT "Accepted: ", Value

(a) Give a name for this type of validation check.

............................................................................................................................................. [1]

(b) Describe what is happening in this validation check.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60

Value OUTPUT

[3]

© UCLES 2019 0478/21/M/J/19


11

(d) Draw a flowchart to represent this section of program code.

[5]
© UCLES 2019 0478/21/M/J/19 [Turn over
12

5 The table, BEVERAGES, shows the number of calories in 100 ml of a range of popular beverages.
It also shows the availability of these drinks in a can, a small bottle and a large bottle.

BevNo BevName Calories Can Small Bottle Large Bottle


Bev01 Cola 40 Yes Yes Yes
Bev02 Lime 45 Yes No Yes
Bev03 Energy Drink 1 52 Yes Yes No
Bev04 Energy Drink 2 43 Yes No No
Bev05 Mango 47 Yes No Yes
Bev06 Lemon Iced Tea 38 Yes No Yes
Bev07 Lemonade 58 Yes Yes Yes
Bev08 Orange Juice 46 Yes Yes No
Bev12 Apple Juice 50 Yes Yes No
Bev15 Chocolate Milk 83 Yes Yes No

(a) Give a reason for choosing BevNo as the primary key for this table.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records shown in the table BEVERAGES.

............................................................................................................................................. [1]

© UCLES 2019 0478/21/M/J/19


13

(c) List the output that would be given by this query-by-example.

Field: BevNo BevName Can Small Bottle Large Bottle

Table: BEVERAGES BEVERAGES BEVERAGES BEVERAGES BEVERAGES

Sort: Descending

Show: ü ü
Criteria: = "Yes" = "Yes" = "Yes"

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(d) Complete the query-by-example grid to output a list showing just the names and primary keys
of all the beverages with a calorie count greater than 45. The list should be in alphabetical
order of names.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2019 0478/21/M/J/19


14

BLANK PAGE

© UCLES 2019 0478/21/M/J/19


15

BLANK PAGE

© UCLES 2019 0478/21/M/J/19


16

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 0478/21/M/J/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 2 5 2 6 7 5 1 7 2 1 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 13 printed pages and 3 blank pages.

DC (LT/JG) 162368/2
© UCLES 2019 [Turn over
2

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

An auction company has an interactive auction board at their sale rooms, which allows buyers to
place bids at any time during the auction. Before the auction starts, the sellers place their items
in the sale room with a unique number attached to each item (item number). The following details
about each item need to be set up on the interactive auction board system: item number, number of
bids, description and reserve price. The number of bids is initially set to zero.

During the auction, buyers can look at the items in the sale room and then place a bid on the
interactive auction board at the sale room. Each buyer is given a unique number for identification
(buyer number). All the buyer needs to do is enter their buyer number, the item number and their bid.
Their bid must be greater than any existing bids.

At the end of the auction, the company checks all the items and marks those that have bids greater
than the reserve as sold. Any items sold will incur a fee of 10% of the final bid to be paid to the
auction company.

Write and test a program or programs for the auction company.

• 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 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 – Auction set up.

For every item in the auction the item number, description and the reserve price should be recorded.
The number of bids is set to zero. There must be at least 10 items in the auction.

Task 2 – Buyer bids.

A buyer should be able to find an item and view the item number, description and the current highest
bid. A buyer can then enter their buyer number and bid, which must be higher than any previously
recorded bids. Every time a new bid is recorded the number of bids for that item is increased by one.
Buyers can bid for an item many times and they can bid for many items.

Task 3 – At the end of the auction.

Using the results from TASK 2, identify items that have reached their reserve price, mark them as
sold, calculate 10% of the final bid as the auction company fee and add this to the total fee for all
sold items. Display this total fee. Display the item number and final bid for all the items with bids that
have not reached their reserve price. Display the item number of any items that have received no
bids. Display the number of items sold, the number of items that did not meet the reserve price and
the number of items with no bids.

© UCLES 2019 0478/22/M/J/19


3

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

Describe the data structures you have used in Task 1 to record the items for sale. Include
some sample data for each data structure you have described.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

(b) Explain how your program for Task 1 ensures the item number is unique.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 0478/22/M/J/19 [Turn over


4

(c) Write an algorithm for the part of Task 2 that allows the buyer to add a new bid, using
either pseudocode, programming statements or a flowchart. Assume that Task 1 has been
completed and that the item details have already been found.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2019 0478/22/M/J/19


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2019 0478/22/M/J/19 [Turn over


6

(d) Explain how your program for Task 2 checks that a new bid is higher than previous bids for
an item.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2019 0478/22/M/J/19


7

(e) Explain how your program identifies the items that have reached their reserve price, then
calculates and displays the total auction company fee for all sold items as part of Task 3. Any
programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2019 0478/22/M/J/19 [Turn over


8

Section B

2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.

Count 1
INPUT Number
High Number
Low Count
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count > 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/22/M/J/19


9

(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/22/M/J/19 [Turn over


10

3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.

START

Total 0
Count 0
Distinction 0

INPUT Mark

Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1

No

No Is OUTPUT "Number of
Mark >= Distinctions ", Distinction
80 ? OUTPUT "Average Mark "
Total/Count
Yes

Distinction Distinction + 1 END

Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45

Total Count Distinction Mark OUTPUT

[4]
© UCLES 2019 0478/22/M/J/19
11

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition


FOR A 1 TO 100
B B + 1
NEXT A
CASE A OF
100: B A
200: C A
ENDCASE
IF A > 100
THEN
B A
ENDIF
REPEAT
A B * 10
UNTIL A > 100
[4]

5 Explain what is meant by validation and verification.


Give an example for each one.

Validation ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Verification ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/22/M/J/19 [Turn over


12

6 A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.

Flight number Plane Notes Departure time Passengers


FN101 Caravan 1 Private passenger flight 08:00 Y
CN101 Caravan 2 Freight only 08:30 N
CN102 Piper 1 Freight only 09:00 N
FN104 Piper 2 Passengers only 09:20 Y
FN105 Piper 1 Freight and passengers 10:00 Y
FN106 Caravan 1 Passengers only 10:30 Y
CN108 Caravan 2 Freight only 08:00 N
CN110 Lear Private passenger flight 08:00 Y

(a) State the field that could have a Boolean data type.

Field .................................................................................................................................... [1]

© UCLES 2019 0478/22/M/J/19


13

(b) A query-by-example has been written to display just the flight numbers of all planes leaving
after 10:00 that only carry passengers.

Field: Flight number Passengers Departure time


Table: FLIGHT FLIGHT FLIGHT
Sort:

Show: 3

Criteria: =Y = 10:00
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:

Show:

Criteria:
or:
[7]

© UCLES 2019 0478/22/M/J/19


14

BLANK PAGE

© UCLES 2019 0478/22/M/J/19


15

BLANK PAGE

© UCLES 2019 0478/22/M/J/19


16

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 0478/22/M/J/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 6 8 8 5 1 6 3 7 0 1 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 15 printed pages and 1 blank page.

DC (ST/ST) 162394/4
© UCLES 2019 [Turn over
2

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 discount stationery store sells items in bulk at a discount to its customers. Customers can order from
a small range of items available on that day. The greater the quantity of an item they buy in one order,
the greater the discount for that item.

Quantity of an item Discount


10 5%
20 10%
50 25%
100 35%
500 50%

In addition to this, new customers can use a $10 voucher, provided their order comes to more than
$50. Also, returning customers are given a discount voucher with a monetary value.

Write and test a program or programs for the discount stationery store.

• 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 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 – Stationery available on the day.

Using arrays, set up a list of at least 10 different items available that day. For every item include: item
code, description, price and the amount in stock. All item codes must be different. Display the item
code, description, price and the amount in stock on the screen.

Task 2 – Customer places an order.

The customer chooses an item code from the list of currently available items. Any items that are out of
stock are not displayed and any items that have low stock of 10 or fewer are highlighted. The customer
enters the number they wish to purchase. If there are not enough items in stock the number is rejected.
The price to pay and any discount is shown on the screen. When the order is complete, any customer
discount voucher is applied and the total price is shown. If the customer confirms the order, the stock
numbers are then updated.

Task 3 – At the end of the day.

List the item codes of any items that have sold out. Display the item code of any items of which none
have been sold. Display the item code and description of the item of which the greatest quantity have
been sold today.
© UCLES 2019 0478/23/M/J/19
3

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

Describe the data structures you have used in Task 1 to record the items available that day.
Include some sample data for each data structure you have described.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

(b) Explain how your program for Task 1 ensures all the item codes are different.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Explain how your program for Task 2 highlights items where the stock level is low.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2019 0478/23/M/J/19 [Turn over


4

(d) Write an algorithm for Task 2 using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed and the list of items currently available
has already been displayed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2019 0478/23/M/J/19


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2019 0478/23/M/J/19 [Turn over
6

(e) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2019 0478/23/M/J/19
7

Question 2 begins on page 8.

© UCLES 2019 0478/23/M/J/19 [Turn over


8

Section B

2 (a) An algorithm has been written in pseudocode to input the weight of 500 items and reject any
that are over-weight or under-weight, then print the percentage rejected.
Count 1
Reject 0
Over 62
Under 58
REPEAT
INPUT ItemWeight
IF ItemWeight > Over AND ItemWeight < Under
THEN
Reject Reject - 1
ENDIF
Count Count + 1
UNTIL Count > = 500
Reject Reject / 100
PRINT "Percentage rejected is ", Reject

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/23/M/J/19


9

(b) Describe how you would change the corrected algorithm to calculate the number accepted
instead of rejected, using a variable Accept, and print a warning if fewer than 50% are
accepted.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/23/M/J/19 [Turn over


10

3 This flowchart inputs the tread depth of five tyres, four on the car and a spare tyre. Any tread
depth of 1.6 mm or less is rejected. To be potentially roadworthy, a car must have four tyres with a
tread depth greater than 1.6 mm.

START

TreadReject 0
Count 1

Is Yes
Count = 6?

Count Count + 1 No
Is No
INPUT Depth TreadReject
<= 1?

Yes OUTPUT "Car is


not roadworthy"

No Is
Depth <=
1.6?

Yes

TreadReject TreadReject + 1

OUTPUT "Car is
potentially
roadworthy"

END

© UCLES 2019 0478/23/M/J/19


11

Complete Trace table 1 for the tread depth input data:


1.7, 1.9, 1.4, 1.8, 2.0

TreadReject Count Depth OUTPUT

Trace table 1

Complete Trace table 2 for the tread depth input data:


1.2, 1.9, 1.4, 1.8, 2.4

TreadReject Count Depth OUTPUT

Trace table 2
[4]

© UCLES 2019 0478/23/M/J/19 [Turn over


12

4 For each of the four checks in the table, place a tick in the correct column to show whether it is an
example of a validation or verification check.

Statements Validation Verification


Range check
Double entry
Check digit
Presence check
[4]

5 Identify and describe three loop structures that are available in pseudocode.

Loop structure 1 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Loop structure 2 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Loop structure 3 ...............................................................................................................................

..........................................................................................................................................................

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/23/M/J/19


13

Question 6 begins on page 14.

© UCLES 2019 0478/23/M/J/19 [Turn over


14

6 A database table, TRAIN, is used to keep a record of train departures from a station.

Train Number Platform Destination Departure Time Status


1A37 1 Newtown 08:00 On time
2X19 2 Anytown 08:10 Late
1A29 1 Bigcity 08:15 On time
1A28 2 Anytown 08:30 Cancelled
1A67 3 Gardenvillage 08:45 On time
1A37 1 Newtown 08:50 On time
1A24 2 Charter Train 09:00 Late
1A67 3 Gardenvillage 09:15 On time

(a) Explain why the field Train Number could not be used as a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2019 0478/23/M/J/19


15

(b) A query-by-example has been written to display only the train numbers and platforms of all
trains leaving after 08:30 that are late.

Field: Train Number Platform Departure Time Status


Table: TRAIN TRAIN TRAIN TRAIN
Sort:
Show: 3
Criteria: =Y < 08:30
or: = "Late"

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:
Show:
Criteria:
or:
[7]

© UCLES 2019 0478/23/M/J/19


16

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 0478/23/M/J/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 8 6 4 9 8 3 8 3 6 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 11 printed pages and 1 blank page.

DC (NH) 162395/3
© UCLES 2019 [Turn over
2

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

You have been asked to write a program to calculate the area of a patio and the cost of the stone slabs
needed to cover it. The program should work for any patio that can be represented as a rectangle, or
group of rectangles that are joined together, and only one type of stone slab may be used.

Type of stone slab Price per square metre

Dover $30.00

Exeter $35.00

London $42.00

Portland $49.50

Shaftesbury $55.00

York $62.75

Write and test a program or programs to calculate the cost of the stone slabs for a patio.

• 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 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 for a simple rectangular patio.


Set up your program to:
• Store the type and price per square metre of the stone slabs using a suitable programming technique.
• Prompt and allow the user to input the length and width of their patio and the type of stone slab they
would like.
• Calculate and display the number of square metres of stone slabs required, rounded up to the next
whole square metre, and the total cost of the stone slabs.

Task 2 – Working on more complex shapes.


Assuming that a patio can be made up of a group of rectangles, extend your program to:
• Enter the number of rectangles making up the patio and the type of stone slab to be used.
• Allow the dimensions for each rectangle to be entered.
• Calculate and display the total area of the patio rounded up to the next whole square metre.
• Calculate and display the total cost of the stone slabs.

Task 3 – Allowing for waste.


It is likely that some of the stone will not be useable, so it is sensible to allow a percentage for wastage,
for example, 10%. Alter your program to allow the user to input a percentage to calculate wastage and
add this to the number of square metres of stone slabs to be purchased, rounded up to the next whole
square metre. Display the revised total area and cost.
© UCLES 2019 0478/21/O/N/19
3

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

Name two variables that you could have used for Task 1. State the data type and purpose of
each variable.

Variable 1 name ........................................................................................................................

Data type ..................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

Variable 2 name ........................................................................................................................

Data type ..................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................
[6]

(b) Describe how arrays could be used to store the data about the types and price per square
metre of the stone slabs for Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

© UCLES 2019 0478/21/O/N/19 [Turn over


4

(c) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. Assume Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2019 0478/21/O/N/19
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]
© UCLES 2019 0478/21/O/N/19 [Turn over
6

(d) Explain how your program completes Task 3. Any programming statements you use in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]
© UCLES 2019 0478/21/O/N/19
7

(e) Name two validation checks that could be used when entering patio dimensions in Task 1 or
Task 2 and describe their purpose.

Validation check 1 .....................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/21/O/N/19 [Turn over


8

Section B

2 For each of the four descriptions in the table, place a tick in the correct column to show whether it
describes a Structure diagram, a Flowchart or Library routines.

Structure Library
Description diagram Flowchart routines
A modelling tool used to show the hierarchy of a
system.
A collection of standard programs available for
immediate use.
A graphical representation used to represent an
algorithm.
A graphical representation to show how a system is
broken into sub-systems.
[4]

3 Examine the following pseudocode:

INPUT A
INPUT B
INPUT C
INPUT D
INPUT E
INPUT F
INPUT G
INPUT H
INPUT I
INPUT J
INPUT K
INPUT L
T A + B + C + D + E + F + G + H + I + J + K + L
OUTPUT "The average equals ", T / 12

(a) Describe what happens in this pseudocode.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

© UCLES 2019 0478/21/O/N/19


9

(b) Describe how this pseudocode could be altered to allow any number of values to be input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(c) Re-write the given pseudocode to allow any number of values to be input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[5]

© UCLES 2019 0478/21/O/N/19 [Turn over


10

4 (a) Complete the trace table for this algorithm using the given input data.

Index 0
FOR Count 0 TO 7
INPUT Value
IF Value > 50
THEN
PassMarks[Index] Value
Index Index + 1
ENDIF
NEXT Count
PRINT "Number passed ", Index

Input data: 58, 40, 67, 85, 12, 13, 75, 82

PassMarks
OUTPUT
Index Count Value [0] [1] [2] [3] [4] [5] [6] [7]

[6]

(b) Give the purpose of the algorithm shown in part (a).

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[1]

© UCLES 2019 0478/21/O/N/19


11

5 A car manufacturer makes a range of car models named Pegasus, Apollo and Cupid. It keeps a
database to store the records of its range and the different options for each car model. Within the
table CAR_RANGE, the following data needs to be stored:

1. Car model
2. Body style – saloon, hatchback or estate
3. How many doors it has
4. Whether it uses petrol, diesel or batteries as fuel
5. An identifier for a specific car.

(a) Complete the table to show suitable field names and an example of appropriate data for each
field in the database table CAR_RANGE.

Field name Example of data

[3]

(b) State which of your fields would be most appropriate for a primary key and give a reason for
your choice.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

(c) Complete the query-by-example grid to provide a list of car models using petrol and the
number of doors these cars have, in alphabetical order of car model. Display only the car
models and the number of doors.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2019 0478/21/O/N/19


12

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 0478/21/O/N/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 1 9 5 1 2 3 8 0 2 2 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 13 printed pages and 3 blank pages.

DC (ST/CT) 162455/3
© UCLES 2019 [Turn over
2

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 company supplies concrete slabs for paving. The slabs are made to order in batches of 20;
all slabs in a batch are identical. Customers can order from a small range of standard sizes and
colours. All measurements are given in millimetres. The price is calculated at $0.05 for a volume of
100 000 mm3 of grey concrete; red and green concrete are charged at 10% more. Customers can
choose their own colours; a custom colour has an initial set up cost of $5 then 15% more than the
price for grey.

Colour of Depth of
Shapes Sizes for each shape
slab slab
Grey 38 Square 600 × 600 or 450 × 450
Red 45 Rectangular 600 × 700 or 600 × 450
Green Round Diameter 300 or 450
Custom

Write and test a program or programs for the concrete slab company.

• 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 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 – Price for a batch of 20 slabs

Using the information above set up a routine that allows a customer to choose the concrete slab
they require and calculate a price for a batch of 20 slabs. The details of the slab chosen and the
price for a batch of 20 should be displayed on the screen.

Task 2 – Customer places an order

Using the information from TASK 1, the customer places an order for the number of slabs they
require. Orders for fewer than 20 slabs or more than 100 slabs are not accepted; orders that are
not a multiple of 20 are rounded up to the next multiple of 20 slabs. Display the order price and the
number of slabs to be produced.

Task 3 – Flexible pricing

The cost of concrete is variable. The cost for 100 000 mm3 of grey concrete can be input and two
grades are available; basic at the cost input and best at 7% more. Use a copy of your program for
TASK 1 to develop TASK 3 to input the cost and grade of concrete before calculating the price for
20 slabs.

© UCLES 2019 0478/22/O/N/19


3

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

(i) Describe the data structures that you have used to store the data for the concrete slabs
in Task 1, include the name, data type and use for each data structure.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(ii) State one variable that you have used in Task 3.


Give the data type for the variable. State what it is used for.

Variable name ...................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[3]

(b) Explain how you calculated the volume of a concrete slab in Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2019 0478/22/O/N/19 [Turn over


4

(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2019 0478/22/O/N/19
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2019 0478/22/O/N/19 [Turn over
6

(d) Explain how you changed your program for Task 1 to meet the requirements for Task 3.
Include and fully explain any altered or additional programming statements.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2019 0478/22/O/N/19
7

Section B

2 An algorithm has been written in pseudocode to select a random number using the function
RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then
allows the user to guess the number.

Number RandInt(100)
TotalTry 1
REPEAT
PRINT "Enter your guess now, it must be a whole number"
INPUT Guess
IF TotalTry > Number
THEN
PRINT "Too large try again"
ENDIF
IF Guess > Number
THEN
PRINT "Too small try again"
ENDIF
TotalTry Guess + 1
UNTIL Guess <> Number
TotalTry TotalTry - 1
PRINT "Number of guesses ", TotalTry

Find the four errors in the pseudocode and suggest a correction to remove each error.

Error 1 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 2 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 3 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................

Error 4 ..............................................................................................................................................

Correction .........................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 0478/22/O/N/19 [Turn over


8

3 (a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.

START

Reject 0
Count 0

Yes
Is Count =
10 ?
No
No
Count Count + 1 Is Reject
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"

Yes Is Length <


25.1 AND
Length > 24.9 ?

No

Reject Reject + 1

OUTPUT "Batch
accepted"

END

© UCLES 2019 0478/22/O/N/19


9

Complete the trace table for the input data:

24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07

Reject Count Length OUTPUT

[4]

(b) (i) It has been decided to only reject batches of rope that contain ropes that are too short.

State the change required to the algorithm.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Explain how the algorithm to reject batches could be improved to make it more effective.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2019 0478/22/O/N/19 [Turn over


10

4 Four validation checks and four descriptions are shown.

Draw a line to connect each validation check to the correct description.

Validation Check Description

Range check Checks that some data is entered.

Checks for a maximum number of characters


Presence check
in the data entered.

Checks that the characters entered are all


Length check
numbers.

Checks that the value entered is between an


Type check
upper value and a lower value.
[3]

5 A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number of baskets. The total weight is stored in a variable Total and the number
of baskets is stored in a variable BasketCount.

Explain, including examples of programming statements, how totalling and counting could be used
in this program.

Totalling .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Counting ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2019 0478/22/O/N/19


11

6 Explain why constants, variables and arrays are used in programming.

Constants .........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Variables ..........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Arrays ...............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/22/O/N/19 [Turn over


12

7 A database table, SALES, is used to keep a record of items made and sold by a furniture maker.

Item number Order number Notes Amount Status


CH001 1921 Smith – six dining chairs 6 Delivered
TB003 1921 Smith – large table 1 In progress
CH001 1924 Hue – extra chairs 4 In progress
CH003 1925 For stock 2 Cancelled
BN001 1927 Patel – replacement bench 1 Not started
ST002 1931 Sola – small table 1 Delivered
CH003 1927 Patel – eight dining chairs with arms 8 Not started
TB003 1927 Patel – large table 1 Not started

(a) Explain why the field Item number could not be used as a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2019 0478/22/O/N/19


13

(b) A query-by-example has been written to display only the order number and item numbers of
any items in progress or not started.

Field: Item number Order number Amount Status


Table: SALES SALES SALES SALES
Sort:
Show: 3 3
Criteria: Not Like "Delivered"
or:

Explain why the query-by-example is incorrect, and write a correct query-by-example.

Explanation ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Field:
Table:
Sort:
Show:
Criteria:
or:
[5]

© UCLES 2019 0478/22/O/N/19


14

BLANK PAGE

© UCLES 2019 0478/22/O/N/19


15

BLANK PAGE

© UCLES 2019 0478/22/O/N/19


16

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 0478/22/O/N/19


Cambridge Assessment International Education
Cambridge International General Certificate of Secondary Education
* 5 6 8 7 7 5 5 2 9 2 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2019
1 hour 45 minutes
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.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

No marks will be awarded for using brand names of software packages or hardware.

Any businesses described in this paper are entirely fictitious.

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 50.

This syllabus is regulated for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 12 printed pages.

DC (SC) 162458/3
© UCLES 2019 [Turn over
2

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

You have been asked to write a program to calculate the area of a wall and the cost of the tiles
needed to cover it. The program should work for any room with up to four walls being tiled. Tiles are
sold in boxes; each box covers one square metre.

Tile description Price per box


Small black granite $19.50
Small grey marble $25.95
Small powder blue $35.75
Medium sunset yellow $12.50
Medium berry red $11.00
Medium glitter purple $52.95
Large oak wood effect $65.00
Large black granite $58.98
Large bamboo effect $85.00
Extra-large white marble $62.75
Write and test a program or programs to calculate the area of the walls and the cost of tiles needed
to tile a room.

• 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 and using the system for a single wall.


Set up your program to:
• Store the tile description, price per box and an identification code using a suitable programming
technique.
• Display the list of tiles including the identification code, description and price per box.
• Prompt the user to input the height and width of the wall, and the identification code of the tiles
they would like.
• Calculate and display the area of the wall, the number of boxes of tiles required (tiles are sold in
boxes of complete square metres) and the total cost of the tiles.

Task 2 – Adding additional walls.


Extend your program to:
• Enter the number of walls to be tiled and the identification code of the tiles to be used. Only one
identification code to be used for all walls.
• Enter the dimensions for each wall to be tiled.
• Calculate and display the total area of all walls, the number of boxes of tiles required (tiles are
sold in boxes of complete square metres) and the total cost of the tiles.

Task 3 – Allowing for waste.


It is likely that some of the tiles will not be useable so it is sensible to allow a percentage for wastage,
for example 10%. Alter your program to allow the user to input a percentage to calculate wastage
and add this to the total area to be tiled. Calculate and display the revised number of boxes of tiles
to be purchased (tiles are sold in boxes of complete square metres) and the total cost of the tiles.
© UCLES 2019 0478/23/O/N/19
3

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

Name two arrays you could use for Task 1. State the data type and purpose of each one.

Array 1 ......................................................................................................................................

Data type 1 ...............................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

Array 2 ......................................................................................................................................

Data type 2 ...............................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................
[4]

(b) Name a variable that you used for Task 2. State the data type and purpose of this variable.
Explain why you chose to use a variable rather than a constant.

Variable .....................................................................................................................................

Data type ..................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Reason for use of a variable .....................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/23/O/N/19 [Turn over


4

(c) Write an algorithm for Task 1, using either pseudocode, programming statements or a
flowchart. Assume that the first part of Task 1, the storage and display of tile descriptions,
prices per box and identification codes has already been done.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2019 0478/23/O/N/19


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2019 0478/23/O/N/19 [Turn over
6

(d) Explain how you extended your program to complete Task 2. Any programming statements
you use in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]
© UCLES 2019 0478/23/O/N/19
7

(e) Explain how you could validate the input for percentage waste allowance in Task 3.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2019 0478/23/O/N/19 [Turn over


8

Section B

2 Describe the use of a subroutine in a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

3 Name the three types of loop structure used in pseudocode.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2019 0478/23/O/N/19


9

4 The following pseudocode algorithm uses nested IF statements.

IF Response = 1
THEN
X X + Y
ELSE
IF Response = 2
THEN
X X – Y
ELSE
IF Response = 3
THEN
X X * Y
ELSE
IF Response = 4
THEN
X X / Y
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF

(a) Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Re-write the pseudocode algorithm using a CASE statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/23/O/N/19 [Turn over


10

5 The algorithm performs an operation on the array named MyData

DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3

First 0
Last 16
Found FALSE
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
Middle (First + Last) DIV 2
IF MyData[Middle] = UserIn
THEN
Found TRUE
ELSE
IF UserIn < MyData[Middle]
THEN
Last Middle - 1
ELSE
First Middle + 1
ENDIF
ENDIF
ENDWHILE
OUTPUT Found

This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5

MyData
Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
Value 2 3 5 6 8 10 12 13 14 16 18 20 25 27 29 34 36

(a) Complete the trace table for the input data: 10

First Last UserIn Middle Found OUTPUT

[6]

(b) Describe the function being performed by the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2019 0478/23/O/N/19
11

6 Draw four different flowchart symbols and describe how they are used in a program flowchart.

Flowchart symbol Description of use

[4]

© UCLES 2019 0478/23/O/N/19 [Turn over


12

7 A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first
name, last name, their year 10 test score and their year 11 test score. The class has 32 students.

(a) State the number of fields and records required for this database.

Number of Fields ......................................................................................................................

Number of Records ..................................................................................................................


[2]

(b) The data in MARKBOOK is stored under category headings: LastName, FirstName,
Y10TestScore and Y11TestScore.

State, with a reason, whether any of these headings would be suitable as a primary key.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Complete the query-by-example grid to only display the first name, last name and year 10
test score of each student who achieved 50 or more in their year 10 test. The output should
be in test score order with the highest marks at the top of the list.

Field:

Table:

Sort:

Show:
Criteria:

or:
[4]

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 0478/23/O/N/19


Cambridge IGCSE™
* 4 6 4 3 3 9 9 2 4 4 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 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 16 pages. Blank pages are indicated.

DC (CJ/FC) 184904/3
© UCLES 2020 [Turn over
2

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 car buying service helps customers calculate the price of buying a new car from Snazzy Autos.
There are three models of car available: hatchback, saloon and estate. A car can be bought with
optional extras.

Model Price Optional extra Price


Hatchback Rs 5.35 lakh Set of luxury seats Rs 45000
Saloon Rs 4.95 lakh Satellite navigation Rs 5500
Estate Rs 6.25 lakh Parking sensors Rs 10000
Bluetooth connectivity Rs 350
Sound system Rs 1000
Snazzy Autos customers buying a new car can trade in an old car. Offers from Rs 10000 to
Rs 1.00 lakh can be made for an old car. If an old car is not traded in, then a discount of 5% is taken
off the price of the new car and any optional extras. In addition, repeat customers are offered a
discount of 10% off any optional extras and 10% off the price of the new car before trade-in.
Customers can either pay for the new car in full or make monthly payments over several years.
Write and test a program or programs for the car buying service.
• 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 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 – Calculate the price
Customers choose the model of car and select any optional extras required. Only valid choices can
be accepted for the model and the extras. The customer is asked if they are an existing customer and
if they have an old car to trade in. If the customer trades in an old car the amount offered by Snazzy
Autos is entered. The price of the new car including model and extras is displayed. Any discount or
trade-in amounts are displayed and the total price to pay is calculated and displayed.
Task 2 – Calculate the payment(s)
Extend Task 1 to display these payment methods:
• full amount paid now customer receives cashback of 1% on the total price
• equal monthly payments are made over four years with no extra charge
• the total price is increased by 5%; equal monthly payments are made over seven years.
For each payment method display: the total amount to pay, the amount of each payment, the number
of payments and cashback where appropriate.
Task 3 – New full amount payment offer
Extend Task 2 to offer customers who decide to pay the full amount now either the 1% cashback or
the chosen optional extras free. Customers are shown the offer that is the best value first and the
other as an alternative. Details of each offer must be displayed in full.
© UCLES 2020 0478/22/F/M/20
3

1 All variables, constants and other identifiers must have meaningful names.

(a) State the name of one constant that you could have used for Task 1. Give the value that
would be assigned to the constant. State the use of this constant.

Constant name .........................................................................................................................

Value .........................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[3]

(b) State the name of the variable that you used to store the amount offered for the trade-in of
an old car in Task 1. Give the most appropriate data type for this variable. Explain how your
program ensured that any data entered for the trade-in offer was valid.

Variable name ...........................................................................................................................

Data type ..................................................................................................................................

Validation ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/F/M/20 [Turn over


4

(c) Snazzy Autos has decided to add another model to the cars available in Task 1. The new
model is a convertible, price Rs 6.75 lakh. Explain the changes required to your program for
Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/22/F/M/20


5

(d) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2020 0478/22/F/M/20 [Turn over


6

(e) Explain how your program completed Task 3. Assume that Task 2 has been completed.
Any programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/22/F/M/20


7

Section B starts on page 8.

© UCLES 2020 0478/22/F/M/20 [Turn over


8

Section B

2 (a) An algorithm has been written in pseudocode to input 50 numbers. Positive numbers are
stored in the array PosNum[ ]. Negative numbers are stored in the array NegNum[ ].
Zeros are not included in the positive and negative counts.

Count 0 ←
PosCount Count ←
NegCount Count ←
REPEAT
INPUT Number
IF Number > 0
THEN
PosCount PosCount + 1 ←
PosNum[PosCount] Number ←
ELSE
NegCount NegCount + 1 ←
NegNum[NegCount] Number ←
ENDIF
Count ←
Count + 1
UNTIL Count >= 50
OUTPUT "There are ", PosCount," positive numbers"
OUTPUT "There are ", NegCount," negative numbers"

Describe the error in the pseudocode and write the correction for this error.

Error ..........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/F/M/20


9

(b) The algorithm needs to be changed so there is no limit to how many numbers can be input.
When the number 9999 is input, the algorithm stops more numbers being input and outputs
the results. The number 9999 is not to be stored nor counted as a positive number.

Explain how you would change the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/22/F/M/20 [Turn over


10

3 This flowchart inputs student percentage marks for three examinations. If the average of these
marks is 80% or over then a distinction grade is awarded. If the average of these marks is less
than 40% then a fail grade is awarded. Otherwise a pass grade is awarded.

START

INPUT
Mark1,Mark2,Mark3

Total Mark1 +
Mark2 + Mark3

Average Total / 3

IS
Yes OUTPUT
Average >= 80 ?
"Distinction"

No

Yes IS
OUTPUT Average < 40 ?
"Fail"

No

OUTPUT
"Pass"

END

© UCLES 2020 0478/22/F/M/20


11

(a) Complete a trace table for each set of input data:

Set 1: 88, 74, 60

Mark1 Mark2 Mark3 Total Average OUTPUT

Set 2: 20, 33, 67

Mark1 Mark2 Mark3 Total Average OUTPUT

Set 3: 79, 91, 70

Mark1 Mark2 Mark3 Total Average OUTPUT

[5]

(b) It has been decided to include an extra grade of Merit when the average of the marks is 60%
or more, and less than 80%. Describe the changes that will need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2020 0478/22/F/M/20 [Turn over


12

4 Explain why validation and verification checks are needed when data is input.
Include an example of each type of check in your answer.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2020 0478/22/F/M/20


13

Question 5 starts on page 14.

© UCLES 2020 0478/22/F/M/20 [Turn over


14

5 A database table, BOX, is used to keep a record of boxes made and sold by a craftsman. Boxes
are categorised by:

• SIZE – small, medium or large


• SHAPE – brief description for example ‘star shaped’
• WOOD – maple, beech, walnut or ebony
• PRICE – price in $
• SOLD – whether the box is sold or not.

A database management system uses these data types:

Text Number Currency Boolean

(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.

SIZE data type ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

SHAPE data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

WOOD data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

SOLD data type ........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[5]

© UCLES 2020 0478/22/F/M/20


15

(b) (i) Complete the query-by-example grid below to only display the price of small walnut
boxes.

Field:

Table:

Sort:

Show:
Criteria:

or:

[3]

(ii) The query-by-example grid from part (b)(i) needs to be changed to show both walnut
and beech boxes and display the wood used. Only one column needs to be changed.
Write the changed column.

Field:

Table:

Sort:

Show:
Criteria:

or:

[2]

© UCLES 2020 0478/22/F/M/20


16

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 2020 0478/22/F/M/20


Cambridge IGCSE™
* 1 4 8 0 2 6 2 6 5 1 *

COMPUTER SCIENCE 0478/21


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 16 pages. Blank pages are indicated.

DC (CJ/CB) 185166/3
© UCLES 2020 [Turn over
2

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 shop sells a range of mobile devices, SIM cards and accessories as shown in the table:
Category Item code Description Price ($)
Phone BPCM Compact 29.99
Phone BPSH Clam Shell 49.99
Phone RPSS RoboPhone – 5-inch screen and 64 GB memory 199.99
Phone RPLL RoboPhone – 6-inch screen and 256 GB memory 499.99
Phone YPLS Y-Phone Standard – 6-inch screen and 64 GB memory 549.99
Phone YPLL Y-Phone Deluxe – 6-inch screen and 256 GB memory 649.99
Tablet RTMS RoboTab – 8-inch screen and 64 GB memory 149.99
Tablet RTLM RoboTab – 10-inch screen and 128 GB memory 299.99
Tablet YTLM Y-Tab Standard – 10-inch screen and 128 GB memory 499.99
Tablet YTLL Y-Tab Deluxe – 10-inch screen and 256 GB memory 599.99
SIM card SMNO SIM Free (no SIM card purchased) 0.00
SIM card SMPG Pay As You Go (SIM card purchased) 9.99
Case CSST Standard 0.00
Case CSLX Luxury 50.00
Charger CGCR Car 19.99
Charger CGHM Home 15.99

Write and test a program or programs for this 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.
Write a program to:
• use appropriate data structures to store the item code, description and price information for the
mobile devices, SIM cards and accessories
• allow the customer to choose a specific phone or tablet
• allow phone customers to choose whether the phone will be SIM Free or Pay As You Go
• allow the customer to choose a standard or luxury case
• allow the customer to choose the chargers required (none, one or both may be purchased)
• calculate the total price of this transaction
• output a list of the items purchased and the total price.
Task 2 – Allow a customer to order multiple mobile devices.
Extend Task 1 to:
• offer the customer the opportunity to purchase an additional mobile device
• if required, perform bulleted steps 2 to 7 of Task 1 for each additional mobile device and
calculate a running total for the customer
• once no further devices are required, output the total the customer will need to pay.
Task 3 – Offering discounts.
Extend the program to allow a discount of 10% off the price of every additional phone or tablet
purchased.
Output the new total the customer will need to pay and the amount of money saved.

© UCLES 2020 0478/21/M/J/20


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify two arrays you could have used for Task 1 and, in each case, state its purpose.

Array 1 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Array 2 ...............................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(ii) Identify two variables you could have used for Task 1 and, in each case, state its
purpose.

Variable 1 ..........................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Variable 2 ..........................................................................................................................

Purpose .............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(b) Explain why the item code data could not be stored as a real data type and identify the most
suitable data type for the item code data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20 [Turn over


4

(c) Write an algorithm to show how you input your choice of mobile device and SIM card (part of
Task 1), using either pseudocode, programming statements or a flowchart. It is not necessary
to show initialisation or setting up of arrays containing product details.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2020 0478/21/M/J/20


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2020 0478/21/M/J/20 [Turn over
6

(d) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2020 0478/21/M/J/20


7

Section B starts on page 8.

© UCLES 2020 0478/21/M/J/20 [Turn over


8

Section B

2 Tick (ü) one box in each row to identify if the statement about structure diagrams is true or false.

True False
Statement
(ü) (ü)
A structure diagram is a piece of code that is available throughout the
structure of a program.
A structure diagram shows the hierarchy of a system.

A structure diagram is another name for an array.

A structure diagram shows the relationship between different components


of a system.
[2]

3 Programs can perform validation and verification checks when data is entered.

(a) Give the names of two different validation checks and state the purpose of each one.

Check 1 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 .....................................................................................................................................

Purpose .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) Give the name of one verification check.

............................................................................................................................................. [1]

(c) Describe the difference between validation and verification.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20


9

4 The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.

Count 0 ←
REPEAT
INPUT Values[Count]
Count ←
Count + 1
UNTIL Count = 0

(a) Explain why the algorithm will never end.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers
below 100 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20 [Turn over


10

5 The flowchart represents an algorithm.

The predefined function DIV gives the value of the result of integer division,
for example, y ← 9 DIV 4 gives y a value of 2

An input value of –1 ends the algorithm.

START

INPUT
Value

IS Yes
Value =
-1 ?

No

Calc1 Value DIV 2

Calc2 Value DIV 3

IS
No Calc1 =
Value / 2 ?

Yes

IS
No Calc2 =
Value / 3 ?

Yes

OUTPUT
Value
END

© UCLES 2020 0478/21/M/J/20


11

(a) Complete the trace table for the input data:

50, 33, 18, 15, 30, –1, 45, 12, 90, 6

Value Calc1 Calc2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/M/J/20 [Turn over


12

6 A garden centre sells garden tools and stores details of these in a database table named TOOLS.
Code is the primary key in the TOOLS table.

Code Description Price ($) Quantity_Stock Quantity_Ordered


GFLG Garden Fork 50.00 1 50
GSLG Garden Spade 50.00 11 0
GHLG Garden Hoe 45.00 8 0
HFSM Hand Fork 9.99 42 0
HSSM Hand Spade 9.99 40 0
HWSM Hand Weeder 9.99 11 0
HS20 Hose (20 metres) 45.00 10 0
HS35 Hose (35 metres) 60.00 2 0
HS50 Hose (50 metres) 75.00 20 60
YBLG Yard Brush 24.99 100 0
LMHD Lawn Mower 99.99 5 0
LMBT Lawn Mower (Battery) 249.99 7 0
LMPT Lawn Mower (Petrol) 349.99 10 25
TRBT Edge Trimmer (Battery) 79.99 15 0
TRPT Edge Trimmer (Petrol) 59.99 20 0
SHSM Shears 40.00 40 0
HCSM Hedge Clippers 40.00 45 0

(a) State the purpose of the primary key in the TOOLS table.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2020 0478/21/M/J/20


13

(b) List the output from the data shown in the table TOOLS that would be given by this query-by-
example.

Field: Code Description Price ($) Quantity_Stock Quantity_Ordered

Table: TOOLS TOOLS TOOLS TOOLS TOOLS

Sort: Descending

Show: ü ü ü
Criteria: >40 >0 >0

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the tools where the quantity in stock is below
25. Only show the Code, Description and Quantity_Stock fields in ascending order of Code.

Field:

Table:

Sort:

Show:

Criteria:

or:

[3]

© UCLES 2020 0478/21/M/J/20


14

BLANK PAGE

© UCLES 2020 0478/21/M/J/20


15

BLANK PAGE

© UCLES 2020 0478/21/M/J/20


16

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 2020 0478/21/M/J/20


Cambridge IGCSE™
* 2 0 3 5 3 9 2 7 0 5 *

COMPUTER SCIENCE 0478/22


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 16 pages. Blank pages are indicated.

DC (CJ/FC) 184928/3
© UCLES 2020 [Turn over
2

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 car park payment system allows customers to select the number of hours to leave their car in the
car park. The customer will get a discount if they enter their frequent parking number correctly. The
system calculates and displays the amount the customer must pay. The price of parking, the number
of hours the customer can enter, and any discount depend upon the day of the week and the arrival
time. The number of hours entered is a whole number. The price per hour is calculated using the
price in force at the arrival time. No parking is allowed between Midnight and 08:00.
Arrival time
Day of the week From 08:00 to 15:59 From 16:00 to Midnight
Max stay in hours Price per hour Hours Price
Sunday 8 2.00 Up to Midnight 2.00
Monday 2 10.00 Up to Midnight 2.00
Tuesday 2 10.00 Up to Midnight 2.00
Wednesday 2 10.00 Up to Midnight 2.00
Thursday 2 10.00 Up to Midnight 2.00
Friday 2 10.00 Up to Midnight 2.00
Saturday 4 3.00 Up to Midnight 2.00

A frequent parking number can be entered for discounted parking. This number consists of 4 digits
and a check digit that is calculated using a modulo 11 check digit calculation. A discount of 50% is
available for arrival times from 16:00 to Midnight; the discount is 10% at all other arrival times.
Write and test a program or programs to simulate the car park payment system.
• 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 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 – Calculating the price to park.
A customer inputs the day, the hour of arrival excluding minutes (for example 15:45 would be 15),
the number of hours to leave their car, and a frequent parking number if available. If the frequent
parking number has an incorrect check digit, then no discount can be applied. The price to park,
based on the day, the hour of arrival, the number of hours of parking required and any discount
available, is calculated and displayed.
Task 2 – Keeping a total of the payments.
Extend Task 1 to keep a daily total of payments made for parking. The daily total is zeroed at the
start of the day. For the simulation, each customer inputs the amount paid, this must be greater than
or equal to the amount displayed. There is no change given so the amount input may exceed the
amount displayed. Each customer payment is added to the daily total, and this total is displayed at
the end of the day.
Task 3 – Making payments fairer.
Customers have complained that sometimes they are being charged too much if they arrive before
16:00 and depart after 16:00. Extend Task 1 to calculate the price before 16:00, then add the
evening charge. For example, a customer arriving at 14:45 on a Sunday and parking for five hours
was previously charged 10.00 and would now be charged 6.00

© UCLES 2020 0478/22/M/J/20


3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify two variables that you could have used for Task 1. Give the data type and state the
use of each variable.

Variable 1 ..................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Variable 2 ..................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[4]

(b) Data input by a customer for Task 1 includes the day and the hour of arrival.

Identify one suitable validation check for each input and justify your choice. Your validation
checks must be different.

Day of arrival – validation check ...............................................................................................

...................................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Hour of arrival – validation check .............................................................................................

...................................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/M/J/20 [Turn over


4

(c) Explain how your program for Task 1 ensured that the frequent parking number entered by
the customer had a valid check digit.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(d) Write an algorithm for part of Task 2 that simulates customer payment and calculating total
payments using either pseudocode, programming statements or a flowchart. Assume that
Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2020 0478/22/M/J/20
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2020 0478/22/M/J/20 [Turn over
6

(e) Explain how your program completed Task 3. Assume that Task 2 has been completed. Any
programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/22/M/J/20


7

Section B

2 Most programming languages include basic data types. Ahmad is describing the basic data types
he has used.

State the data type that Ahmad is describing in each sentence.

Choose the data type from this list of programming terms.

Array Boolean Char Constant Function Integer

Iteration Procedure Real String Variable

A number with a fractional part that can be positive or negative and used in calculations

Data type ..........................................................................................................................................

A whole number that can be positive, negative or zero and used in calculations

Data type ..........................................................................................................................................

A single number, symbol or letter

Data type ..........................................................................................................................................

A sequence of characters

Data type ..........................................................................................................................................

A data type with two values, True or False

Data type ..........................................................................................................................................


[5]

© UCLES 2020 0478/22/M/J/20 [Turn over


8

3 (a) An algorithm has been written in pseudocode to input the names and marks of 35 students.
The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest
mark awarded is found and the number of students with that mark is counted. Both of these
values are output.

01 HighestMark 100 ←
02 HighestMarkStudents 0 ←
03 FOR Count ←
1 TO 35
04 OUTPUT "Please enter student name"
05 INPUT Name[Count]
06 OUTPUT "Please enter student mark"
07 INPUT Mark[Counter]
08 IF Mark[Count] = HighestMark
09 THEN
10 HighestMarkStudents HighestMarkStudents – 1 ←
11 ENDIF
12 IF Mark[Count] > HighestMark
13 THEN
14 Mark[Count] HighestMark ←
15 HighestMarkStudents 1 ←
16 ENDIF
17 NEXT Count
18 OUTPUT "There are ", HighestMarkStudents," with the highest mark of ",
HighestMark

Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/22/M/J/20


9

(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2020 0478/22/M/J/20 [Turn over
10

4 This flowchart inputs the points won and the points lost when playing a game. The difference
between the points won and lost is calculated and depending on the result the player can: move
up to the next level, stay at the same level, or move down to the previous level. The flowchart
finishes when the input for points won is –1.

START

INPUT
PointsWon, PointsLost

IS
Yes END
PointsWon = –1 ?

No

Difference
PointsWon - PointsLost

OUTPUT IS
Yes
"Well done Difference > =
move up" 1000 ?

No

OUTPUT Yes IS
"Sorry move Difference < 0 ?
down"

No

OUTPUT
"Keep on trying"

© UCLES 2020 0478/22/M/J/20


11

(a) Complete a trace table for this set of input data:


5000, 4474, 6055, 2000, 7900, 9800, 3000, 2150, –1, 6700, 7615

PointsWon PointsLost Difference OUTPUT

[3]

(b) The flowchart needs to be changed. When the difference is more than 5000 the output
message is ‘Fantastic leap up two levels’.

Describe the changes that will need to be made to the flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2020 0478/22/M/J/20 [Turn over


12

5 Arrays are data structures used in programming. Explain what is meant by the terms dimension
and index in an array. Use examples of arrays in your explanations.

Dimension ........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Index ................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2020 0478/22/M/J/20


13

6 A database table, JUICE, is used to keep a record of cartons of fresh fruit juice available for sale.

Juice code Fruit 1 Fruit 2 Size Volume (ml) Stock level


LMO10 Mango Orange Large 1000 18
MOO05 Orange Orange Medium 500 8
SAM02 Apple Mango Small 200 25
SAA02 Apple Apple Small 200 50
SPP02 Pineapple Pineapple Small 200 10
MMM05 Mango Mango Medium 500 12
LMM10 Mango Mango Large 1000 5
MGG05 Guava Guava Medium 500 5
SMO02 Mango Orange Small 200 7
MOP05 Orange Pineapple Medium 500 12
LAA10 Apple Apple Large 1000 32
SGO02 Guava Orange Small 200 10
LPP10 Pineapple Pineapple Large 1000 3
LOO10 Orange Orange Large 1000 25
SOO02 Orange Orange Small 200 40

(a) Identify a suitable field to use as the primary key. State a reason for your choice.

Field ..........................................................................................................................................

Reason ......................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the stock level and size of all cartons
containing only apple juice.

Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

© UCLES 2020 0478/22/M/J/20


14

BLANK PAGE

© UCLES 2020 0478/22/M/J/20


15

BLANK PAGE

© UCLES 2020 0478/22/M/J/20


16

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 2020 0478/22/M/J/20


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

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 Item code Description Price ($) Healthy?
Fruit FR1 Apple 1.00 Yes
Fruit FR2 Banana 1.25 Yes
Fruit FR3 Orange 1.00 Yes
Fruit FR4 Peach 1.30 Yes
Sandwich SN1 Cheese 1.75 Yes
Sandwich SN2 Cheese and Tomato 2.20 Yes
Sandwich SN3 Chicken 2.00 Yes
Sandwich SN4 Chicken Salad 2.35 Yes
Sandwich SN5 Salad (Vegetarian) 2.00 Yes
Crisps CR1 Salted 1.00 No
Crisps CR2 Cheese and Onion 1.00 No
Crisps CR3 Barbecue 1.00 No
Crisps CR4 Prawn Cocktail 1.00 No
Confectionery CN1 Biscuits 0.95 No
Confectionery CN2 Chocolate Bar 1.05 No
Confectionery CN3 Toffee and Chocolate Bar 1.25 No
Confectionery CN4 Chocolate Wafers 1.30 No
Drink DR1 Cola 1.20 No
Drink DR2 Lemon and Lime Soda 1.20 No
Drink DR3 Orange Soda 1.20 No
Drink DR4 Orange Juice 1.50 Yes
Drink DR5 Apple Juice 1.50 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 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

(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

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2020 0478/23/M/J/20 [Turn over
6

(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

(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

Section B

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

Description Pseudocode example

A loop that will iterate


CASE … OF … OTHERWISE … ENDCASE
at least once

A loop that will not be


executed on the first test Number Number + 1
if the condition is false

A conditional statement WHILE … DO … ENDWHILE

Totalling Sum Sum + NewValue

Counting REPEAT … UNTIL

[4]

© UCLES 2020 0478/23/M/J/20


9

3 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 PRINT "Input a number from 0 to 499 inclusive"


2 FOR Number 1 TO 10
3 INPUT Number
4 IF Number < 0 AND Number > 499
5 THEN
6 PRINT "Invalid number, please try again"
7 ENDIF
8 UNTIL Number = 0 OR Number = 499
9 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 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


11

5 This algorithm finds prime numbers.

The pre-defined function DIV gives the value of the result of integer division,
for example, y 9 DIV 4 gives y a value of 2

Flag False
INPUT Number
WHILE Number <> 0
Divisor 2
WHILE Divisor <= Number / 2
Value Number DIV Divisor
IF Number / Divisor = Value
THEN
Flag True
ENDIF
Divisor Divisor + 1
ENDWHILE
IF Flag = False
THEN
OUTPUT Number, " is prime"
ENDIF
INPUT Number
Flag False
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


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


Cambridge IGCSE™
* 5 2 7 8 6 0 5 5 8 3 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 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 16 pages. Blank pages are indicated.

DC (ST/CT) 185129/2
© UCLES 2020 [Turn over
2

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 car insurance system allows customers to check how much it would cost to buy insurance for a car for
twelve months. The starting price of the car insurance is $500. The actual price a customer pays for the car
insurance changes depending upon this information:
• engine size of car
• value of car
• where car is kept overnight
• number of kilometres (km) driven a year
• age of driver
• years insured without an insurance claim
Engine Kept 1000 km Years
Price Value in Price Price Price Age of Price Price
size in over- driven a without
change $1000 change change change driver change change
litres night year claim
<=0.5 –5% <0.5 –5% Garage –5% <5 –5% 18–20 +100% 1 –10%
>0.5 to 1.0 0% 0.5 to 2 0% Drive 0% 5 to 20 0% 21–25 +50% 2 –20%
>1.0 to 2.5 +5% >2 to 10 +5% Street +5% >20 +5% 26–30 +25% 3 –30%
>2.5 +10% >10 to 20 +10% 31–70 0% 4 –40%
>20 +15% 71–80 +10% 5 –50%
>80 +20% 6 –60%
>6 –70%
Table 1 Table 2
The actual price is calculated by:
• finding the total of the percentage changes for the customer using Table 1
• applying this total percentage change to the starting price of the car insurance
• applying the years without claim discount percentage for the customer using Table 2.
Write and test a program or programs to calculate the price for a customer to insure a car.
• 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 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 – Calculate the price to insure a car.
Write a program to obtain the required information from a customer and calculate the price to insure the car.
Display the price to insure the car. Display the total percentage change calculated from Table 1, and the
years without claim discount percentage from Table 2 separately.
Task 2 – New customer discount.
Extend Task 1 to include an additional discount of 10% off the price to any new customer who is aged
between 26 and 70 inclusive, who also has 2 or more years without a claim. Display the amount of money
this would save and the new price.
Task 3 – Adding an extra driver.
Customers can add one extra driver. The age of the extra driver may increase the price. The new price is
calculated by applying the percentage price change for the age of the extra driver from Table 1 to the price.
Extend Task 2 to calculate and display the new price including an extra driver if required.

© UCLES 2020 0478/21/O/N/20


3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one array that you could have used for Task 1. Give the data type and state the use
of the array.

Array .........................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(b) Data entered by a customer includes the age of the driver in Task 1.
Identify two different validation checks you could use for the age of the driver.
Justify your choice for each one.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2020 0478/21/O/N/20 [Turn over


4

(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2020 0478/21/O/N/20


5

(d) (i) Explain how your program completed Task 3. Assume that Task 2 has been completed.
Any programming statements used in your answer must be fully explained.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]

© UCLES 2020 0478/21/O/N/20 [Turn over


6

(ii) The car insurance system needs updating to record the percentage of customers who
bought car insurance after obtaining a price to insure a car. Describe the changes
required to your program.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2020 0478/21/O/N/20


7

Section B

2 Describe the purpose of variables and constants. Use an example of each in your answer.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2020 0478/21/O/N/20 [Turn over


8

3 This pseudocode algorithm calculates the weight and number of bags in a load of firewood. The
weight in kilograms of each bag is input. The algorithm finishes when either 50 bags have been
weighed, or as soon as the total weight exceeds 1000 kilograms. Only then are the total weight
and the number of bags in the load output.

01 TotalWeight ←
1000
02 BagCount 0 ←
03 MaxBag 50 ←
04 MaxWeight ←
1000
05 REPEAT
06 OUTPUT "Please Enter weight of bag"
07 INPUT Weight
08 TotalWeight ←
TotalWeight + Weight
09 BagCount ←
BagCount + 1
10 OUTPUT "Number of bags in the load is ", BagCount
11 UNTIL TotalWeight > MaxWeight AND BagCount >= MaxBag
12 OUTPUT "Total weight of the load is ", MaxWeight

(a) Give the line number(s) from the algorithm of:

an assignment statement .........................................................................................................

a loop ........................................................................................................................................

a counting statement ................................................................................................................

a totalling statement .................................................................................................................


[4]

(b) Give the line numbers of the four errors in this pseudocode. Suggest a correction for each
error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2020 0478/21/O/N/20
9

(c) Explain how you could extend the algorithm to calculate and display the average weight of a
bag of firewood in the load.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/21/O/N/20 [Turn over


10

4 This flowchart inputs five numbers and performs a calculation.

The predefined function MOD finds the remainder from integer division for example
R ← 25 MOD 11 gives R a value of 3

START

INPUT
V,W,X,Y,Z

IS Yes
V = 0? END

No

A ← V*2 + W*3 + X*4 + Y*5

B ← A MOD 11

Yes IS
OUTPUT
"Valid" B = Z?

No

OUTPUT
"Invalid"

© UCLES 2020 0478/21/O/N/20


11

(a) Complete the trace table for this set of input data:
5, 4, 6, 2, 1, 9, 3, 2, 1, 6, 7, 6, 1, 5, 1, 0, 0, 0, 0, 0

V W X Y Z A B OUTPUT

[4]

(b) Describe the purpose of this flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/O/N/20 [Turn over


12

5 A database table, AIRLINE, stores data used to compare airlines.

Number of Number of Head office Share price


Code Airline name
employees countries
FJ FastJet 60000 30 Europe 514.50
MA MurphyAir 35000 8 Europe 152.67
JS JetSeven 45000 22 Asia 257.44
K3 Koala3 22000 11 Australia 501.21
NS NorthState 30000 4 America 108.22
SS SouthState 30000 4 America 126.35
BJ BlueJet 15000 7 Africa 215.45
SK SkyKing 32000 27 Europe 506.12
PF PandaFly 50000 35 Asia 317.88

(a) State how many fields and how many records are shown in the AIRLINE table.

Number of Fields ......................................................................................................................

Number of Records ..................................................................................................................


[2]

(b) Show the output that would be given by this query-by-example.

Field: Airline name Number of employees Head office Share price


Table: AIRLINE AIRLINE AIRLINE AIRLINE
Sort:

Show: 3 3
Criteria: < 35000 > 500.00
or:

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/21/O/N/20


13

(c) Complete the query-by-example grid to find every airline with a head office in Asia or Africa,
and number of countries greater than 4. Only show the airline name and number of countries.

Field:

Table:
Sort:

Show:
Criteria:
or:

[4]

© UCLES 2020 0478/21/O/N/20


14

BLANK PAGE

© UCLES 2020 0478/21/O/N/20


15

BLANK PAGE

© UCLES 2020 0478/21/O/N/20


16

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 2020 0478/21/O/N/20


Cambridge IGCSE™
* 1 1 2 9 1 3 8 4 5 2 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 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 (ST) 185711/3
© UCLES 2020 [Turn over
2

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

An online computer shop sells customised personal computers. Every computer sold includes a basic set of
components costing $200 and additional items can be added from the table:
Category Item code Description Price ($)
Case A1 Compact 75.00
Case A2 Tower 150.00
RAM B1 8 GB 79.99
RAM B2 16 GB 149.99
RAM B3 32 GB 299.99
Main Hard Disk Drive C1 1 TB HDD 49.99
Main Hard Disk Drive C2 2 TB HDD 89.99
Main Hard Disk Drive C3 4 TB HDD 129.99
Solid State Drive D1 240 GB SSD 59.99
Solid State Drive D2 480 GB SSD 119.99
Second Hard Disk Drive E1 1 TB HDD 49.99
Second Hard Disk Drive E2 2 TB HDD 89.99
Second Hard Disk Drive E3 4 TB HDD 129.99
Optical Drive F1 DVD/Blu-Ray Player 50.00
Optical Drive F2 DVD/Blu-Ray Re-writer 100.00
Operating System G1 Standard Version 100.00
Operating System G2 Professional Version 175.00
As well as the basic set of components every computer must include one case, one RAM and one Main Hard
Disk Drive from the table.
A computer is supplied with or without an Operating System.
Write and test a program or programs for the online computer 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 and ordering the main items.
Write a program to:
• use arrays to store the item code, description and price
• allow a customer to choose one case, one RAM and one Main Hard Disk Drive
• calculate the price of the computer using the cost of the chosen items and the basic set of components
• store and output the chosen items and the price of the computer.
Task 2 – Ordering additional items.
Extend TASK 1 to:
• allow a customer to choose whether to purchase any items from the other categories – if so, which
item(s)
• update the price of the computer
• store and output the additional items and the new price of the computer.
Task 3 – Offering discounts.
Extend TASK 2 to:
• apply a 5% discount to the price of the computer if the customer has bought only one additional item
• apply a 10% discount to the price of the computer if the customer has bought two or more additional
items
• output the amount of money saved and the new price of the computer after the discount.
© UCLES 2020 0478/22/O/N/20
3

1 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 the benefits of storing Price as a real data type.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/22/O/N/20 [Turn over


4

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

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2020 0478/22/O/N/20
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2020 0478/22/O/N/20 [Turn over


6

(d) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2020 0478/22/O/N/20
7

(e) Describe how you could alter your program to allow more than one computer to be bought.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/22/O/N/20 [Turn over


8

Section B

2 Tick (3) one box in each row to identify if the statement about subroutines is true or false.

true false
Statement
(3) (3)
A subroutine is called from within a program.

A subroutine is not a complete program.

A subroutine is a self-contained piece of code.

A subroutine must return a value to the code from which it was called.
[2]

3 This pseudocode algorithm is used as a validation check.

PRINT "Input a number from 1 to 5000"


REPEAT
INPUT Number
IF Number < 1 OR Number > 5000
THEN
PRINT "Invalid number, please try again"
ENDIF
UNTIL Number >= 1 AND Number <= 5000
PRINT Number, " is within the correct range"

Identify three different types of test data. For each type, give an example of the test data you
would use to test this algorithm and state a reason for your choice of test.

Type of test data 1 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 2 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

Type of test data 3 ...........................................................................................................................

Test data ...........................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2020 0478/22/O/N/20


9

4 This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.

FOR Count 1 TO 5000


INPUT Number[Count]
NEXT Count

Extend and re-write the algorithm using pseudocode to also count and output how many of the
numbers stored in the array are greater than 500, using the variable Higher. Only output Higher
once with an appropriate message.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [6]
© UCLES 2020 0478/22/O/N/20 [Turn over
10

5 This pseudocode represents an algorithm.

REPEAT
Flag 0
FOR Count 0 to 3
IF Num[Count] < Num[Count + 1]
THEN
Store Num[Count]
Num[Count] Num[Count + 1]
Num[Count + 1] Store
Flag 1
ENDIF
NEXT Count
UNTIL Flag = 0

(a) The contents of the array at the start of the algorithm are:

Num[0] Num[1] Num[2] Num[3] Num[4]


45 56 30 12 15

Complete the trace table for the algorithm using the data given in the array.

Flag Count Num[0] Num[1] Num[2] Num[3] Num[4] Store


45 56 30 12 15

[5]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]
© UCLES 2020 0478/22/O/N/20
11

6 Draw a flowchart symbol to represent each of the following:

Input/Output Decision

[2]

Question 7 starts on Page 12.

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/22/O/N/20 [Turn over


12

7 The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.

PartNum Description Cost Quantity


A01 Compact Amplifier Case 50.00 15
A02 Deluxe Amplifier Case 75.00 1
A03 Amplifier Standard 79.99 48
A04 Amplifier Midrange 149.99 50
A05 Amplifier Megablaster 299.99 48
S01 Tweeter 59.99 10
S02 Midrange Woofer 99.99 0
S03 Subwoofer 139.99 16
S04 Tower Speaker Basic 159.99 25
S05 Tower Speaker Skyscraper 219.99 9
S06 Centre Speaker 149.99 25
S07 Soundbar 89.99 2
S20 Soundbar 129.99 0
S21 Ceiling Surround Speaker 75.00 15
S22 Ceiling Full Range Speaker 100.00 1
S25 Surround Speaker 100.00 60
T19 Speaker Stands (Pair) 75.00 60

(a) State the number of records in the table AUDIOPARTS

............................................................................................................................................. [1]

(b) Identify the field that is most suitable to be a primary key and give a reason for your choice.

Fieldname .................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[2]

(c) Complete the query-by-example grid to show the items where the quantity in stock is fewer
than 10. Show all the fields from the database table in descending order of cost.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]
© UCLES 2020 0478/22/O/N/20
Cambridge IGCSE™
* 0 4 0 5 0 8 6 6 6 5 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 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 16 pages. Blank pages are indicated.

DC (ST/JG) 185347/3
© UCLES 2020 [Turn over
2

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 baguette ordering service allows customers to order filled baguettes. There are two sizes of
baguette: 30 cm and 15 cm. Baguettes are available as white, brown or seeded bread. Baguettes
have one filling and can have up to three salad items added.
Filling and salad choices are:

Filling Salad
Beef Lettuce
Chicken Tomato
Cheese Sweetcorn
Egg Cucumber
Tuna Peppers
Turkey

Customers choose their baguette options. They then confirm their order, alter their choices or choose
not to proceed.
Each day the ordering service calculates the number of each:
• size of baguette sold
• type of bread (white, brown or seeded) sold
• filling sold.
Write and test a program or programs for the baguette ordering service.
• 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 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 – Ordering.
Customers are given choices on size, type of bread, filling and salad items as shown. Only valid
choices can be accepted. The customer is asked to confirm their order, alter their choices or choose
not to proceed. If the customer confirms their order they are given a unique order number. Display
the baguette ordered and the order number.

Task 2 – Recording the choices.


Extend TASK 1 to record totals for the size, types of bread and fillings sold that day and calculate
the total number of baguettes sold that day.

Task 3 – Finding the most and least popular baguette fillings.


Using your results from TASK 2, display the most popular and least popular fillings as a percentage
of the total number of baguettes sold that day.

© UCLES 2020 0478/23/O/N/20


3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one constant and identify one variable that you could have used for Task 1. Give the
value that would be assigned to the constant. Give the data type for the variable. State what
each one could be used for.

Constant ...................................................................................................................................

Value .........................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Variable .....................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[6]

(b) (i) Write an algorithm to allow a customer to choose the filling and salad items for their
baguette (part of Task 1), using either pseudocode, programming statements or a
flowchart. Your algorithm must only include this part of Task 1.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
© UCLES 2020 0478/23/O/N/20 [Turn over
4

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
© UCLES 2020 0478/23/O/N/20
5

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(ii) Explain how your algorithm in part (b)(i) ensured that only valid choices were accepted
for the filling.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(c) Explain how you would need to change your program for Task 1 if there were three sizes of
baguette to choose from (15 cm, 20 cm and 30 cm).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/23/O/N/20 [Turn over


6

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

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/23/O/N/20


7

Section B starts on Page 8.

© UCLES 2020 0478/23/O/N/20 [Turn over


8

Section B

2 An algorithm has been written in pseudocode to check the temperature readings taken from a
freezer are within the range –18 degrees to –25 degrees inclusive.

The algorithm counts the number of times that the temperature reading is below –25 degrees and
the number of times that the temperature reading is above –18 degrees.

An engineer is called if there are more than 10 temperature readings below –25 degrees.

An alarm sounds if there are more than 5 temperature readings above –18 degrees.

01 TooHot 0
02 TooCold 1000
03 REPEAT
04 OUTPUT "Please enter temperature"
05 INPUT Temperature
06 IF Temperature < -25
07 THEN
08 TooCold TooCold – 1
09 ENDIF
10 IF Temperature > -18
11 THEN
12 TooHot TooHot + 1
13 ENDIF
14 UNTIL TooHot > 5 OR TooCold > 10
15 IF TooHot < 5
16 THEN
17 INPUT "Alarm!!"
18 ENDIF
19 IF TooCold > 10
20 THEN
21 OUTPUT "Call the Engineer"
22 ENDIF

(a) Give the line number(s) from the algorithm of:

an assignment statement .........................................................................................................

a loop ........................................................................................................................................

a counting statement ................................................................................................................

a selection statement ................................................................................................................


[4]

© UCLES 2020 0478/23/O/N/20


9

(b) Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

(c) Explain how you could extend the algorithm to count the number of times the temperature
readings are within the range –18 degrees to –25 degrees inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2020 0478/23/O/N/20 [Turn over


10

3 Four programming concepts and five descriptions are shown.

Draw a line to connect each Programming concept to its correct Description. Not all Descriptions
will be connected to a Programming concept.

Programming concept Description

A subroutine that does not have to


Validation
return a value

An automatic check to ensure that data


input is reasonable and sensible
Verification

A subroutine that always returns


a value

Procedure
An overview of a program or subroutine

A check to ensure that data input


Function
matches the original
[4]

© UCLES 2020 0478/23/O/N/20


11

Question 4 starts on Page 12.

© UCLES 2020 0478/23/O/N/20 [Turn over


12

4 This flowchart represents an algorithm that allows the input of two numbers and performs a
calculation.

The predefined function MOD finds the remainder from integer division for example X 8 MOD 5
gives X a value of 3.

START

INPUT
Y,Z

IS Yes
Y = 0? END

No

IS Yes
Y > Z? A Y MOD Z

No

A Z MOD Y

OUTPUT Yes IS
"Valid" A = 0?

No

OUTPUT
"Invalid"

© UCLES 2020 0478/23/O/N/20


13

(a) Complete a trace table for this set of input data:


11, 4, 6, 2, 3, 9, 3, 2, 2, 6, 0, 0, 1, 1

Y Z A OUTPUT

[4]

(b) Explain the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/23/O/N/20 [Turn over


14

5 A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.

Creature Class Quantity Ready for release Offspring


Manta Ray Fish 3 Y N
Short-tailed Albatross Bird 4 Y N
Emperor Penguin Bird 50 Y Y
Bluefin Tuna Fish 2 N N
Manatee Mammal 4 Y N
Hawksbill Turtle Reptile 10 Y Y
Hammerhead Shark Fish 3 Y N
Yellow-eyed Penguin Bird 4 Y N
Kemp’s Ridley Sea Turtle Reptile 1 Y N

(a) State how many fields and how many records are shown in this table.

Number of fields .......................................................................................................................

Number of records ....................................................................................................................


[2]

(b) Show the output that would be given by this query-by-example.

Field: Creature Class Ready for release

Table: MARINE MARINE MARINE

Sort:

Show: 3 3
Criteria: ="Bird"

or:

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 0478/23/O/N/20


15

(c) Complete the query-by-example grid to display the creatures, in ascending order of quantity,
that have no offspring and are ready for release. Display only the creature field.

Field:

Table:

Sort:

Show:
Criteria:

or:

[4]

© UCLES 2020 0478/23/O/N/20


16

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 2020 0478/23/O/N/20


Cambridge IGCSE™


COMPUTER SCIENCE 0478/02


Paper 2 Problem-solving and Programming For examination from 2020
SPECIMEN PAPER
1 hour 45 minutes
Candidates answer on the question paper.
No additional materials are required.

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.
Calculators must not be used in this paper.

Answer all questions.

DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.

You are advised to spend no more than 40 minutes on Section A (Question 1).

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 50.

This document consists of 13 printed pages and 1 blank page.

© UCLES 2019 [Turn over


2

BLANK PAGE

© UCLES 2019 0478/02/SP/20


3

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 Section A Question 1.

Pre-release material

A teacher needs a program to record marks for a class of 30 students who have sat three computer
science tests.

Write and test a program for the teacher.

• Your program must include appropriate prompts for the entry of data.
• Error messages and other output need to be set out clearly and understandably.
• All 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 – Set up arrays

Set-up one dimensional arrays to store:

• Student names
• Student marks for Test 1, Test 2 and Test 3
o Test 1 is out of 20 marks
o Test 2 is out of 25 marks
o Test 3 is out of 35 marks
• Total score for each student

Input and store the names for 30 students. You may assume that the students’ names are unique.

Input and store the students’ marks for Test 1, Test 2 and Test 3. All the marks must be validated on
entry and any invalid marks rejected.

TASK 2 – Calculate

Calculate the total score for each student and store in the array.
Calculate the average total score for the whole class.

Output each student’s name followed by their total score.


Output the average total score for the class.

TASK 3 – Select

Select the student with the highest total score and output their name and total score.

© UCLES 2019 0478/02/SP/20 [Turn over


4

1 (a) All variables, constants and other identifiers should have meaningful names.

(i) Declare the array to store the students’ names.

[1]

(ii) Declare the arrays to store each student’s marks and total score.

[2]

(b) (i) Show the design of your algorithm to complete Task 1 and Task 2 using pseudocode,
programming statements or a flowchart. Do not include any of the validation checks or
input prompts in your algorithm.

[8]

© UCLES 2019 0478/02/SP/20


5

(ii) Comment on the efficiency of your design.

[1]

(c) Show two different sets of student data that you could use to check the validation used in
Task 1. Explain why you chose each data set.

Set 1

Reason for choice

Set 2

Reason for choice

[2]

© UCLES 2019 0478/02/SP/20 [Turn over


6

(d) (i) Explain how you select the student with the highest score (Task 3). You may include
pseudocode or programming statements to help illustrate your explanation.

[5]

(ii) How does your program work when there is more than one student having the highest
score? Explain using your method given in part (d)(i).

[1]

© UCLES 2019 0478/02/SP/20


7

Section B

2 Jatinder uses Internet banking.


This pseudocode checks her PIN.

c ← 0
INPUT PIN
x ← PIN
REPEAT
x ← x/10
c ← c + 1
UNTIL x < 1
IF c <> 5
THEN
PRINT “error in PIN entered”
ELSE
PRINT “PIN OK”
ENDIF

(a) What value of c and what message would be output if the following PINs were entered?

5 1 0 2 0 Value of c:

Message:

5120 Value of c:

Message: [2]

(b) What type of validation check is being carried out here?

[1]

© UCLES 2019 0478/02/SP/20 [Turn over


8

3 The flowchart inputs the size of a number of car engines; a value of –1 stops the input.

This information is output: average engine size and number of engines with size > 1.5

© UCLES 2019 0478/02/SP/20


9

Complete the trace table for the input data.

1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1

Engine Count Number Size Average OUTPUT

[6]

© UCLES 2019 0478/02/SP/20 [Turn over


10

4 Read this section of program code that inputs twenty (20) numbers and then outputs the largest
number input.

1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20

There are three errors in this code.

Locate these errors and suggest a corrected piece of code.

[3]

© UCLES 2019 0478/02/SP/20


11

5 A database table, TREES, is used to keep a record of the trees in a park. Each tree is given a
unique number and is examined to see if it is at risk of dying. There are over 900 trees; part of the
database table is shown.

Tree Number Type Map Position Age in Years At Risk

TN091 Acacia A7 250 Y

TN172 Olive C5 110 N

TN913 Cedar B9 8 N

TN824 Banyan A3 50 Y

TN021 Pine D5 560 Y

TN532 Teak C8 76 Y

TN043 Yew B1 340 N

TN354 Spruce D4 65 N

TN371 Elm B10 22 Y

TN869 Oak C9 13 N

TN954 Pine E11 3 N

(a) State the number of fields in the table.

[1]

(b) Using the query-by-example grid, write a query to identify at risk trees over 100 years old.
Display only the type and the position on the map.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

© UCLES 2019 0478/02/SP/20 [Turn over


12

6 (a) Write an algorithm, using pseudocode or flowchart only, which:

• inputs three numbers


• outputs the largest of the three numbers

[3]

(b) Write an algorithm, using pseudocode or flowchart only, which:

• inputs 1000 numbers


• outputs how many of these numbers were whole numbers (integers)
(You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)

[4]

© UCLES 2019 0478/02/SP/20


13

(c) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]

7 A database was set up to show the properties of certain chemical elements. Part of the database
is shown below.

Name of Element Atomic Atomic Melting Boiling State at


element symbol number weight point (C) point (C) room temp

oxygen O 8 16 –218 –183 gas

iron Fe 26 56 1538 2861 solid

mercury Hg 80 201 –38 356 liquid

bromine Br 35 80 –7 59 liquid

osmium Os 76 190 3033 5012 solid

caesium Cs 55 133 28 671 solid

gallium Ga 31 70 30 2204 solid

argon Ar 18 40 –189 –186 gas

silver Ag 47 108 961 2162 solid

(a) How many fields are in each record?

[1]

(b) The following search condition was entered:

(Melting point (C) < 40) AND (Atomic weight > 100)

Using Element symbol only, which records would be output?

[2]

(c) Which field would be best suited as primary key?

[1]

© UCLES 2019 0478/02/SP/20


14

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.

Cambridge Assessment International Education 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.

© UCLES 2019 0478/02/SP/20


Cambridge IGCSE™
* 0 7 9 8 1 7 3 6 4 5 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 2021

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 16 pages. Any blank pages are indicated.

DC (CE/SG) 202680/2
© UCLES 2021 [Turn over
2

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 program is needed for a quiz to help younger students to practise their multiplication tables. There
needs to be two ways of using the quiz; testing and learning.
Testing: the student is given one attempt at answering each question and the score is calculated for
the whole test.
Learning: the student is given up to three attempts to get their answer to each question correct. There
is no scoring.
A student can choose which multiplication table, from 2 to 12, to use for the quiz. There are five
questions in each quiz, each question must use the chosen multiplication table and a different whole
number (from 1 to 12) as the multiplier.
Write and test a program or programs for a multiplication tables quiz.
• 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 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 – Testing a student
Students enter their name and choice of multiplication table. Each question is displayed on the screen
one at a time, for example:

Question 1

2X7=

Students enter their answer and move on to the next question. A running total of correct answers
(score) is kept. At the end of the quiz the student’s name and score are displayed with a personalised
message related to the score, for example:

Aarav your score is 5/5 Diya your score is 3/5

Well done full marks Have another practice

Task 2 – Student learning


Students enter their name and choice of multiplication table. Each question is displayed on the screen
as in Task 1. If an answer is correct, a personalised message containing the student’s name confirms
this, the quiz then moves to the next question. If an answer is incorrect, a personalised message
containing the student’s name and a hint is displayed, for example:

Aarav your answer is too large

Up to three attempts are offered to get each answer correct. After the third incorrect attempt, the correct
answer is displayed and the quiz moves on to the next question.
Task 3 – Varying the quiz
Modify Task 1 to allow students to choose how many questions they would like in the test and if they
would like a ‘mixed’ set of questions. A ‘mixed’ set means that each question can be from a different
multiplication table; from 2 to 12.
© UCLES 2021 0478/22/F/M/21
3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify the variable that you used to store the student’s answer in Task 1. Give the most
appropriate data type for this variable. Explain how your program ensured that any data
entered for the answer was valid.

Variable .....................................................................................................................................

Data type ..................................................................................................................................

Validation ..................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) Identify and give the data type of a different variable, that you could have used in Task 2.
State the use of this variable in Task 2.

Variable .....................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2021 0478/22/F/M/21 [Turn over


4

(c) Write an algorithm for Task 1, using either pseudocode, programming statements or a
flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2021 0478/22/F/M/21


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2021 0478/22/F/M/21 [Turn over
6

(d) Explain how your program completed Task 3.


Include any programming statements that you have added to Task 1 and fully explain the
purpose of each statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/22/F/M/21


7

(e) Explain how you could alter Task 1 to change the quiz to:

• display three alternative answers for each question


• allow the student to choose one of these answers

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/22/F/M/21 [Turn over


8

Section B

2 An algorithm has been written in pseudocode to:

• input 25 positive whole numbers less than 100


• find and output the largest number
• find and output the average of all the numbers

01 A ←0
O2 B ←0
03 C ←0
04 REPEAT
05 REPEAT
06 INPUT D
07 UNTIL D > 0 AND D < 100 AND D = INT(D)
08 IF D > B
09 THEN
10 B D ←
11 ENDIF
12 C ← C + D
13 A ← A + 1
14 UNTIL A >= 25
15 E ←C / A
16 OUTPUT "Largest number is ", B
17 OUTPUT "Average is ", E

(a) Give the line number for the statements showing:

Totalling ....................................................................................................................................

Counting ...................................................................................................................................

Range check .............................................................................................................................

Calculating the average ............................................................................................................


[4]

(b) State an example for each type of test data needed to test the input of the number:

Normal test data example .........................................................................................................

Erroneous/abnormal test data example ....................................................................................

Extreme test data example .......................................................................................................


[3]

© UCLES 2021 0478/22/F/M/21


9

(c) The algorithm needs to be changed to include finding and outputting the smallest number input.
Describe how you would change the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

3 Four pseudocode statements and three flowchart symbols are shown.

Draw a line from each pseudocode statement to its correct flowchart symbol.

Pseudocode statement Flowchart symbol

IF X > 12

INPUT X

X Y + Z

OUTPUT X

[4]

© UCLES 2021 0478/22/F/M/21 [Turn over


10

4 This algorithm accepts weights of bags of cookies. Any cookie bag weighing between 0.9 and
1.1 kilograms inclusive is acceptable. Underweight bags weigh less than 0.9 kilograms and
overweight bags weigh more than 1.1 kilograms. An input of a negative number stops the process.
Then the total number of bags, the number of overweight bags and the number of underweight
bags weighed are output.

Accept← 0
Over ← 0
Under← 0
OUTPUT "Enter weight of first cookie bag"
INPUT BagWeight
WHILE BagWeight > 0
IF BagWeight > 1.1
THEN
Error ← 1
ELSE
IF BagWeight < 0.9
THEN
Error ← 2
ELSE
Error ← 0
ENDIF
ENDIF
CASE Error OF
0 : Accept ← Accept + 1
1 : Over ← Over + 1
2 : Under ← Under + 1
ENDCASE
OUTPUT "Weight of next bag?"
INPUT BagWeight
ENDWHILE
Total ← Accept – Over – Under
OUTPUT "Number of bags weighed ", Total
OUTPUT "Number overweight ", Over
OUTPUT "Number underweight ", Under

© UCLES 2021 0478/22/F/M/21


11

(a) Complete a trace table for the given algorithm using this input data:
1.05, 0.99, 1.2, 0.85, 1.1, 0.9, 1.5, 0.95, 1.05, 1.00, 1.07, 0.89, –10

BagWeight Accept Over Under Error Total OUTPUT

[7]

(b) There is an error in this algorithm.


Identify the error and write the corrected pseudocode statement.

Error ..........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2021 0478/22/F/M/21 [Turn over


12

5 A database table, CHOCBAR, is used to keep a record of chocolate bars sold. Chocolate bars are
categorised by:

• SIZE – small or large


• FILLING – brief description, for example mint crunch
• PRICE – price in Rupees, for example ₹2.50
• NUMBERSOLD – how many sold

A database management system uses these data types:

Text Number Currency Boolean

(a) Select the most appropriate data type for these three fields from the four data types shown.
Each data type must be different. State the reason why you chose the data type.

SIZE data type ..........................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

NUMBERSOLD data type ........................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[3]

(b) Complete the query-by-example grid below to display only the price, filling and number sold
of small chocolate bars that have sold fewer than 10 bars.

Field:

Table:

Sort:

Show:

Criteria:

or:

[3]

© UCLES 2021 0478/22/F/M/21


13

BLANK PAGE

© UCLES 2021 0478/22/F/M/21


14

BLANK PAGE

© UCLES 2021 0478/22/F/M/21


15

BLANK PAGE

© UCLES 2021 0478/22/F/M/21


16

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 2021 0478/22/F/M/21


Cambridge IGCSE™
* 8 1 2 9 3 2 0 6 3 8 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2021

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 16 pages. Any blank pages are indicated.

DC (CJ/AR) 202720/2
© UCLES 2021 [Turn over
2

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 system is required to record and count votes for candidates in school council elections. The voting
system will allow for one representative to be elected from a tutor group. The school has between
28 and 35 students in each tutor group, five year groups named Year 7 to Year 11, and there are six
tutor groups in each year group. Tutor group names are their year group followed by a single letter
e.g. 7A, 7B, etc.
All students are allowed to vote in the system. Each student may only vote once for a representative
from their tutor group in the election.
Write and test a program or programs for the voting system.
• 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 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 voting system to allow a tutor group to elect a representative.
Write a program to:
• allow the tutor to enter the name of the tutor group
• allow the tutor to enter the number of students in the tutor group
• allow the tutor to enter the number of candidates in the election; maximum of four candidates
• allow the tutor to enter the names of the candidates and store them in a suitable data structure
• allow each student to input their vote or to abstain
• count the votes for each candidate and student abstentions.
When all students have voted, display the name of the tutor group, the votes for each candidate
and the name of the candidate who has won the election. If there is a tie for first place, display all
candidates with the equal highest number of votes.
Task 2 – Checking that students only vote once.
Each student is given a unique voter number by their teacher.
Extend Task 1 to achieve the following:
• Allow students to enter their unique voter number before casting their vote.
• Check whether the student has already voted:
– if so, supply a suitable message and do not allow them to vote.
– if not, store the unique voter number, but not their vote, in a suitable data structure, and
add their vote to the relevant candidate count or abstention.
Task 3 – Showing statistics and dealing with a tie.
Extend Task 2 to achieve the following:
• Calculate the percentage of the votes that each candidate received from the number of votes
cast, excluding abstentions.
• Display the name of each candidate, the number of votes and the percentage of votes they
received from the number of votes cast, excluding abstentions.
• Display the total number of votes cast in the election and the number of abstentions.
• In the event of a tie, allow the election to be immediately run again, with only the tied candidates
as candidates, and all the students from the tutor group voting again.
© UCLES 2021 0478/21/M/J/21
3

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

(i) Identify one constant you could have used for Task 1, give the value that would be
assigned to it and its use.

Constant ............................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) Identify one variable and one array you could have used for Task 1.
Explain the use of each one.

Variable .............................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Array ..................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(b) Explain how you should change your program in Task 1 to allow a tutor to enter up to eight
candidates for the election.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/21/M/J/21 [Turn over


4

(c) Write an algorithm using pseudocode, programming statements or a flowchart to show how
your program completes these parts of Task 2:
• Allows students to enter their unique voter number before casting their vote.
• Checks whether the student has already voted:
– if so, supplies a suitable message and does not allow them to vote.
– if not, stores the unique voter number, but not their vote, in a suitable data structure.

It is not necessary to show parts completed in Task 1, including counting of votes for each
candidate.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2021 0478/21/M/J/21


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2021 0478/21/M/J/21 [Turn over


6

(d) Explain how your program completes these parts of Task 3:


• Calculate the percentage of the votes that each candidate received from the number of
votes cast, excluding abstentions.
• Display the name of each candidate, the number of votes and the percentage of votes
they received from the number of votes cast, excluding abstentions.
• Display the total number of votes cast in the election and the number of abstentions.

Any programming statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2021 0478/21/M/J/21
7

Section B

2 Tick (ü) one box in each row to identify if the statement is about validation, verification or both.

Validation Verification Both


Statement
(ü) (ü) (ü)
Entering the data twice to check if both entries are
the same.
Automatically checking that only numeric data has
been entered.
Checking data entered into a computer system
before it is stored or processed.
Visually checking that no errors have been
introduced during data entry.
[3]

3 Name and describe the most appropriate programming data type for each of the examples of data
given. Each data type must be different.

Data: 37

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: Cambridge2021

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Data: 47.86

Data type name ................................................................................................................................

Data type description .......................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 0478/21/M/J/21 [Turn over


8

4 The pseudocode algorithm shown has been written by a teacher to enter marks for the students in
her class and then to apply some simple processing.

Count 0 ←
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
Grade[Count] "A" ←
ELSE
IF Score[Count] >= 60
THEN
Grade[Count] "B" ←
ELSE
IF Score[Count] >= 50
THEN
Grade[Count] "C" ←
ELSE
IF Score[Count] >= 40
THEN
Grade[Count] "D" ←
ELSE
IF Score[Count] >= 30
THEN
Grade[Count] "E" ←
ELSE
Grade[Count] "F" ←
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Count ←
Count + 1
UNTIL Count = 30

(a) Describe what happens in this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/M/J/21


9

(b) Write the pseudocode to output the contents of the arrays Score[] and Grade[] along with
suitable messages.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/M/J/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered.

START

INPUT
Value

IS Yes
Value =
–1 ?
OUTPUT
"Reject: END
No
Abnormal"

IS
No Value >= 50
AND Value
<= 100 ?

Yes

Diff1 100 – Value

Diff2 Value – 50

IS
OUTPUT No Diff1 < 1 OR
"Accept: Normal" Diff2 < 1 ?

Yes

OUTPUT
"Accept:
Extreme"

© UCLES 2021 0478/21/M/J/21


11

(a) Complete the trace table for the input data:

50, 75, 99, 28, 82, 150, –1, 672, 80

Value Diff1 Diff2 OUTPUT

[4]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2021 0478/21/M/J/21 [Turn over


12

6 A library uses a database table, GENRE, to keep a record of the number of books it has in each
genre.

ID GenreName Total Available Loaned Overdue


ABI Autobiography 500 250 250 20
BIO Biography 650 400 250 0
EDU Education 20200 10000 10200 1250
FAN Fantasy 1575 500 1075 13
GFI General Fiction 35253 23520 11733 0
GNF General Non-Fiction 25200 12020 13180 0
HFI Historical Fiction 6300 3500 2800 0
HNF Historical Non-Fiction 8000 1523 6477 0
HUM Humour 13500 9580 3920 46
MYS Mystery 26000 13269 12731 0
PFI Political Fiction 23561 10523 13038 500
PNF Political Non-Fiction 1823 750 1073 23
REF Reference 374 374 0 0
ROM Romance 18269 16800 1469 0
SAT Satirical 23567 12500 11067 0
SCF Science Fiction 36025 25000 11025 0
SPO Sport 45720 32687 13033 3256
THR Thriller 86000 46859 39141 0

(a) State the reason ID could be used as a primary key in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

(b) State the number of records in the table GENRE.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/21/M/J/21


13

(c) Complete the query-by-example grid to display any genres with overdue books. Only display
the ID, GenreName and Overdue fields in order of the number of books overdue from largest
to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

© UCLES 2021 0478/21/M/J/21


14

BLANK PAGE

© UCLES 2021 0478/21/M/J/21


15

BLANK PAGE

© UCLES 2021 0478/21/M/J/21


16

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 2021 0478/21/M/J/21


Cambridge IGCSE™
* 0 3 3 7 1 8 6 9 5 9 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2021

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 16 pages. Any blank pages are indicated.

DC (LK) 202758/1
© UCLES 2021 [Turn over
2

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

An electric mountain railway makes four return trips every day. In each trip the train goes up the
mountain and back down. The train leaves from the foot of the mountain at 09:00, 11:00, 13:00 and
15:00. The train returns from the top of the mountain at 10:00, 12:00, 14:00 and 16:00. Each train
has six coaches with eighty seats available in each coach. Passengers can only purchase a return
ticket; all tickets must be purchased on the day of travel. The cost is $25 for the journey up and
$25 for the journey down. Groups of between ten and eighty passengers inclusive get a free ticket
for every tenth passenger, provided they all travel together (every tenth passenger travels free).
Passengers must book their return train journey, as well as the departure train journey, when they
purchase their ticket. Passengers can return on the next train down the mountain or a later train.
The last train from the top of the mountain has two extra coaches on it.

The train times are displayed on a large screen, together with the number of tickets still available
for each train. Every time a ticket is booked the display is updated. When a train is full, the word
‘Closed’ is displayed instead of the number of tickets available.

Write and test a program or programs for the electric mountain railway.

• 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 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 – Start of the day.


Write a program to set up the screen display for the start of the day. Initialise suitable data structure(s)
to total passengers for each train journey and total the money taken for each train journey. Each
train journey must be totalled separately. There are four journeys up and four journeys down every
day.

Task 2 – Purchasing tickets.


Tickets can be purchased for a single passenger or a group. When making a purchase, check
that the number of tickets for the required train journeys up and down the mountain is available. If
the tickets are available, calculate the total price including any group discount. Update the screen
display and the data for the totals.

Task 3 – End of the day.


Display the number of passengers that travelled on each train journey and the total money taken
for each train journey. Calculate and display the total number of passengers and the total amount
of money taken for the day. Find and display the train journey with the most passengers that day.

© UCLES 2021 0478/22/M/J/21


3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify and give the data type and use of one array that you could have used for Task 1.

Array .........................................................................................................................................

Data type ..................................................................................................................................

Use ...........................................................................................................................................
[3]

(b) Describe two validation checks that could be used when inputting the number of tickets to
buy for Task 2. For each validation check give one example of normal data and one example
of erroneous data.

Validation check 1 .....................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Normal data ..............................................................................................................................

Erroneous data .........................................................................................................................

Validation check 2 .....................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Normal data ..............................................................................................................................

Erroneous data .........................................................................................................................


[6]

© UCLES 2021 0478/22/M/J/21 [Turn over


4

(c) Write an algorithm for the part of Task 2 that inputs the tickets required, calculates the total
price for the ticket(s) purchased by a passenger including a group discount (if applicable) and
updates the data structures used for the totals.
Use either pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2021 0478/22/M/J/21
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/22/M/J/21 [Turn over


6

(d) Explain how your program completed Task 3. Include any programming statements that you
have used and fully explain the purpose of each statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2021 0478/22/M/J/21


7

Section B starts on page 8

© UCLES 2021 0478/22/M/J/21 [Turn over


8

Section B

2 (a) Write an algorithm in pseudocode to input 500 positive whole numbers. Each number input
must be less than 1000. Find and output the largest number input, the smallest number input
and the range (difference between the largest number and smallest number).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/22/M/J/21


9

(b) Describe how the algorithm could be changed to make testing less time-consuming.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

3 (a) Draw the most appropriate flowchart symbol for each pseudocode statement.

Pseudocode statement Flowchart symbol

IF Number = 20

PRINT Number

Number ← Number + 1

[3]

(b) State the type of each pseudocode statement. For example, X ← X + Y is totalling.
IF Number = 20 ...................................................................................................................

PRINT Number ........................................................................................................................

Number ← Number + 1 ......................................................................................................


[3]

© UCLES 2021 0478/22/M/J/21 [Turn over


10

4 This algorithm checks passwords.

• Each password must be 8 or more characters in length; the predefined function Length
returns the number of characters.
• Each password is entered twice, and the two entries must match.
• Either Accept or Reject is output.
• An input of 999 stops the process.

REPEAT
OUTPUT "Please enter password"
INPUT Password
IF Length(Password) >= 8
THEN
INPUT PasswordRepeat
IF Password <> PasswordRepeat
THEN
OUTPUT "Reject"
ELSE
OUTPUT "Accept"
ENDIF
ELSE
OUTPUT "Reject"
ENDIF
UNTIL Password = 999

(a) Complete the trace table for the algorithm using this input data:
Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888

Password PasswordRepeat OUTPUT

[3]

© UCLES 2021 0478/22/M/J/21


11

(b) Explain how the algorithm could be extended to allow three attempts at inputting the matching
password. Any pseudocode statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................ [4]

5 A one-dimensional array dataArray[1:20] needs each element set to zero.

(a) Write a pseudocode routine that sets each element to zero. Use the most suitable loop
structure.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain why you chose this loop structure.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/22/M/J/21 [Turn over


12

6 A database table, PLANT, is used to keep a record of plants sold by a nursery. The table has these
fields:
• NAME – name of plant
• FLOWER – whether the plant flowers (True) or not (False)
• POSITION – shade, partial shade or sun
• SIZE – small, medium or large
• PRICE – price in $
• NUMBERSOLD – how many sold

A query-by-example grid has been completed to display only the price, name and number sold of
small plants that do not flower.

Field: NAME PRICE NUMBERSOLD SIZE FLOWER POSITION

Table: PLANT

Sort:

Show: 3 3 3

Criteria: = "shade"

or:

Identify the errors in the query-by-example grid.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Rewrite the corrected query-by-example grid.

Field:

Table:

Sort:

Show:

Criteria:

or:

[5]

© UCLES 2021 0478/22/M/J/21


13

BLANK PAGE

© UCLES 2021 0478/22/M/J/21


14

BLANK PAGE

© UCLES 2021 0478/22/M/J/21


15

BLANK PAGE

© UCLES 2021 0478/22/M/J/21


16

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 2021 0478/22/M/J/21


Cambridge IGCSE™
* 9 0 6 0 9 6 0 7 7 2 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2021

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.

DC (KN/SG) 202761/2
© UCLES 2021 [Turn over
2

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 would like a system to allow students and staff to show their preference on matters relating
to the school, such as a proposal for changing the start and finish times of the school day.
Option Proposed start and finish times of the school day
A Start: 08:00 – Finish: 15:00
B Start: 08:20 – Finish: 15:20
C Start: 08:40 – Finish: 15:40
D Start: 09:00 – Finish: 16:00
E Start: 09:30 – Finish: 16:30
The school has 150 students and 20 members of staff. The system is required to accept preferences,
and count and report the results to show student preferences, staff preferences and overall results.
Write and test a program or programs for the system.
• 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 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 and recording preferences.
Set up a system to allow preferences to be recorded for each of five different options, labelled A to E.
• Allow a description for each option to be entered.
• Allow students and staff to enter their unique number before their preferences can be entered
(everyone is given a unique number by the school).
• Check if the unique number has already been used:
○ if so, supply a suitable message and do not allow preferences to be entered
○ if not:
• record that the entered unique number has been used
• allow preferences from 1 to 5 to be entered for each option (1 is ‘strongly agree’ and
5 is ‘strongly disagree’)
• store the preferences in suitable data structures, keeping student and staff preferences
separate.
Task 2 – Totalling the preferences and reporting the results.
Extend Task 1 to achieve the following:
• Allow the preferences for each of the options to be totalled, keeping student and staff
preferences separate.
• Display the results as a list of the options, with the totals given for each one as:
○ student results
○ staff results
○ combined results.
Task 3 – Changing the program to include a counting method.
Extend Task 2 to achieve the following:
• Count the number of times the preference 1, ‘strongly agree’, was given for each option,
counting student and staff preferences separately.
• Display the results as a list of the options, with the number of times preference 1 was given for
each option as:
○ student results
○ staff results
○ combined results.

© UCLES 2021 0478/23/M/J/21


3

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

(i) Identify one constant you could have used for Task 1. Give the value that would be
assigned to the constant and explain its use.

Constant ............................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) Identify one variable you could have used for Task 1 and explain its use.

Variable .............................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]

(iii) Describe one array you could have used for Task 1. Include the name, data type, length,
sample data and use for that array.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]

© UCLES 2021 0478/23/M/J/21 [Turn over


4

(b) Write an algorithm for Task 2, using pseudocode, programming statements or a flowchart. It
is not necessary to show details completed in Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2021 0478/23/M/J/21
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2021 0478/23/M/J/21 [Turn over
6

(c) Explain how you could change your program in Task 1 to allow the number of options
available to be increased to six.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(d) Explain how your program counts the number of times students enter preference 1 (‘strongly
agree’) for each option (A to E), part of Task 3. Any programming statements used in your
answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/23/M/J/21


7

Section B

2 Draw a line to connect each Data Type to the most appropriate Description.

Data Type Description

Real Must be a whole number

String Must be one of two values

Integer May be any number

Boolean May contain any combination of characters


[3]

3 Identify a suitable validation check that could be used for each piece of normal test data and
describe how it would be used. Each validation check must be different.

Test data for entering an email address: [email protected]

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Test data for entering a year: 2021

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Test data for entering a name: Ericson-Bower

Validation check name .....................................................................................................................

Description of use ............................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]
© UCLES 2021 0478/23/M/J/21 [Turn over
8

4 The pseudocode algorithm should allow a user to input the number of scores to be entered and
then enter the scores. The scores are totalled, the total is output and the option to enter another
set of scores is offered.

1 Count 0 ←
2 REPEAT
3 FullScore 20 ←
4 INPUT Number
5 FOR StoreLoop 1 TO Number ←
6 INPUT Score
7 FullScore FullScore ←
8 UNTIL StoreLoop = Number
9 OUTPUT "The full score is ", FullScore
10 OUTPUT "Another set of scores (Y or N)?"
11 OUTPUT Another
12 IF Another = "N"
13 THEN
14 Count 1 ←
15 ENDIF
16 UNTIL Count = 1

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/M/J/21


9

(b) Show how you could change the algorithm to store the individual scores in the array
ScoreArray[], then find and print the average score once the scores have all been entered.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/23/M/J/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if 0 is entered at the Op input.

START

INPUT
Op

IS No
Op = 0 ?

Yes
INPUT
Value1

INPUT
Value2

IS Yes
Op = 1 ? Ans Value1 + Value2

END No

IS Yes
Op = 2 ? Ans Value1 - Value2

No

IS Yes
Op = 3 ? Ans Value1 * Value2

No

IS Yes
Op = 4 ? Ans Value1 / Value2

No

OUTPUT
"Input Error"

© UCLES 2021 0478/23/M/J/21


11

(a) Complete the trace table for the algorithm using this input data:

1, 87, 14, 3, 2, 30, 5, 10, 6, 4, 10, 2, 0, 2, 90, 6

Op Value1 Value2 Ans OUTPUT

[5]

(b) State the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Suggest an addition that could be made to the algorithm to make it more useful.

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2021 0478/23/M/J/21 [Turn over


12

6 A car hire company uses a database table, TREAD, to store details of the cars. The table has
fields to represent each car’s licence number, mileage, and the tread depth of each of its four
tyres.

(a) Suggest suitable names for each of the fields described.

Field name

[2]

(b) Complete the query-by-example grid to display cars where all four tyres have a tread depth
of less than 2. Display all the fields, using the field names you created in part (a). The output
should be sorted by licence number.

Field:

Table:

Sort:

Show: o o o o o o
Criteria:

or:
[4]

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 2021 0478/23/M/J/21


Cambridge IGCSE™
* 0 6 7 1 1 5 7 2 5 3 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2021

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 16 pages. Any blank pages are indicated.

DC (RW/AR) 202716/5
© UCLES 2021 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release material

A holiday park has eight squash courts that can be booked for an hour at a time. The first booking
is from 08:00 to 09:00 and the last booking is from 17:00 to 18:00. All bookings start on the hour
and bookings can only be made on the same day that the squash court is used. A screen displays
today’s date and how many squash courts are available for each hour.

When a booking is made, the name of the guest is recorded together with their mobile phone number.
Once the squash court is booked, the guest is shown the court number together with a unique 4-digit
code that can be used to unlock the squash court. Each booking is for one squash court for one
hour. The 4-digit code must be different for each booking.

Write and test a program or programs for a computer system to manage the daily squash court
bookings.

• 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 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 – at the start of the day

Write a program to set up arrays to record the following for each hour:
• whether a squash court is booked or available
• the name of the guest
• the mobile phone number of the guest
• the unique 4-digit code for the booking.
Set up a screen to display the court availability at the start of the day.

Task 2 – making a squash court booking

Check if there is a squash court available at the time requested. If a squash court is available,
record the guest’s name and mobile phone number. Mark the squash court as booked for that hour.
Generate and record the unique 4-digit code for the booking. Display the mobile phone number for
the guest to check, display the court number and the 4-digit code for the guest to remember. Display
the updated court availability, showing an hour as fully booked if all the squash courts are now
booked for that hour.

Task 3 – at the end of the day

Calculate the total number of squash court bookings. Find the hour(s) and court(s) with the most
bookings. Display this information.

© UCLES 2021 0478/21/O/N/21


3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one constant that you could have used for Task 1. Give the value that would be
assigned to this constant. State the use of this constant.

Constant ...................................................................................................................................

Value .........................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[3]

(b) Describe the arrays that you have set up in Task 1 to record today’s data about the squash
courts.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(c) Explain how your program generates a unique 4-digit code for each booking.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/O/N/21 [Turn over


4

(d) Write an algorithm for Task 2. You do not need to display updated court availability. Use
either pseudocode, programming statements or a flowchart. Assume that Task 1 has been
completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2021 0478/21/O/N/21


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/21/O/N/21 [Turn over


6

(e) Explain how your program completed the part of Task 3 which calculates the total number of
squash court bookings, finds the court(s) with the most bookings and displays this information.
Include any programming statements that you have used and fully explain the purpose of
each statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/21/O/N/21


7

Section B starts on Page 8

© UCLES 2021 0478/21/O/N/21 [Turn over


8

Section B

2 An algorithm has been written in pseudocode to generate 50 positive random integers with values
less than or equal to 100. These random integers are stored in the array RandNum[ ]

The function Rand(X, Y) generates a random integer greater than or equal to X and less than Y.
For example, Rand(1, 4) generates 1 or 2 or 3.

1 Count 0
2 REPEAT
3 RandNum[Counter] Rand(1, 100)
4 Count Count + 2
5 UNTIL Count <= 50

(a) Find the four errors in the pseudocode and write a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/21/O/N/21


9

(b) The pseudocode for this algorithm could be shortened by the use of a FOR … NEXT loop.

Rewrite the algorithm using a FOR … NEXT loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Identify another loop structure available in pseudocode.

............................................................................................................................................. [1]

3 A program has been written to check the value of a measurement. The measurement must be a
positive number and given to three decimal places, for example, 3.982

(a) (i) State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.

Normal test data example .................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

Erroneous test data example ............................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................
[4]

(ii) Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2021 0478/21/O/N/21 [Turn over


10

(b) Explain why verification is needed and how verification could be performed by this program.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/21/O/N/21


11

Question 4 starts on Page 12

© UCLES 2021 0478/21/O/N/21 [Turn over


12

4 The algorithm shown by this flowchart allows the input of examination marks for a class of students.
A mark of –1 ends the process. If a mark is 80 or over then a distinction grade is awarded. The
number of distinctions for the whole class is calculated. If this is over 50% of the class, the class is
awarded a highly commended certificate.

START

←0
←0
Counter
Distinction

INPUT
Mark

IS
Mark = –1?
Yes
Award ← Distinction/Counter
No

Counter ← Counter + 1 IS
Award > 0.5?
Yes OUTPUT
"Highly
Commended"

No

Distinction ← Distinction + 1
END

Yes IS
Mark >= 80?

No

© UCLES 2021 0478/21/O/N/21


13

Complete a trace table for the algorithm using this input data:
88, 74, 60, 90, 84, 87, 95, 72, 84, 66, –1

Counter Distinction Mark Award OUTPUT

[5]

© UCLES 2021 0478/21/O/N/21 [Turn over


14

5 A database table, APPLIANCE, is used to keep a record of kitchen appliances available for sale.

The following data is stored for each appliance:

• CATEGORY – washer, dishwasher, fridge or freezer


• ECONOMYRATING – A, B, C or D
• MANUFACTURER – Baku or ABC
• PRICE – price in $
• CODE – a unique code allocated by the manufacturer e.g. B982
• STOCK – number in stock.

The database management system uses these data types:

Text Number Currency Boolean

The ECONOMYRATING field and MANUFACTURER field have a data type of text.

(a) Identify the most appropriate data type for each field from the four types shown. State the
reason why you chose each data type.

CATEGORY data type ..............................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

CODE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

STOCK data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/21/O/N/21


15

(b) Complete the query-by-example grid to display only the category, manufacturer and code of
the appliances with an economy rating of A.

Field:
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2021 0478/21/O/N/21


16

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 2021 0478/21/O/N/21


Cambridge IGCSE™
* 8 1 3 0 5 0 5 1 1 4 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2021

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.

DC (LK/FC) 202711/3
© UCLES 2021 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release material

An integrated transport system has been designed to reduce the need for privately owned vehicles.
A vehicle is booked to take a passenger from home to a start station, from where they will travel to
an end station. A vehicle at the end station will take the passenger to their destination. Each stage
of the journey has a price code to represent the distance travelled. The prices for each stage are
shown:

Home to start Start station to end End station to


station station destination
Code Price ($) Code Price ($) Code Price ($)
C1 1.50 M1 5.75 F1 1.50
C2 3.00 M2 12.50 F2 3.00
C3 4.50 M3 22.25 F3 4.50
C4 6.00 M4 34.50 F4 6.00
C5 8.00 M5 45.00 F5 8.00
To book a journey, a passenger will enter a code for each stage and the start time of their journey.
The total price is calculated by adding together the price for each of the three stages. The total
price will be reduced by 40% when the start time of the journey is after 10:00.

Write and test a program or programs for the integrated transport booking system.
• 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 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 booking system


Write a program to set up arrays to record the following:
• codes and prices for each of the three stages
• passenger accounts that include a unique passenger account number and name
• bookings that include a unique passenger account number, a start time of the journey, a code
for each stage of the journey, and a unique booking number for the journey.
Store the data for the code and price for each stage.

Task 2 – using the booking system


Extend Task 1 to achieve the following:
• Allow passengers to open an account by generating a unique passenger account number and
storing it along with their name in the arrays.
• Allow passengers to make a booking by first entering their unique passenger account number,
the start time of their journey, and a code for each stage of their journey. Check if the passenger
account number already exists.
• Generate a unique booking number for the journey.
• Calculate the total price of the journey, without any discount, and store the journey details.

Task 3 – applying a discount and checking the entry


Extend Task 2 to check the start time of the journey and if it is after 10:00, apply a 40% discount to
the total price.
Display the total price and booking details for the passenger to check, and allow them to either
confirm the details are correct or start again.

© UCLES 2021 0478/22/O/N/21


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one variable you could have used for Task 2 and state its use.

Variable .............................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]

(ii) Describe the arrays you could have used in Task 1. Include the name, data type, use
and sample data for each array.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(b) Describe how you could validate the data entry for the input of the codes for the different
stages of the journey in Task 2.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/22/O/N/21 [Turn over


4

(c) Write an algorithm to show how your program carries out Task 3, using either pseudocode,
programming statements or a flowchart. Assume Tasks 1 and 2 have already been completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2021 0478/22/O/N/21


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/22/O/N/21 [Turn over


6

(d) Explain how your program could be changed to count and store the number of bookings
made by each passenger. Then, after ten bookings have been made by a passenger, apply
an additional 10% discount to every future booking. Any programming statements used in
your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2021 0478/22/O/N/21
7

Section B

2 Tick (3) one box in each row to identify if the statement is about validation, verification or neither.

Validation Verification Neither


Statement
(3) (3) (3)
a check where data is re-entered to make sure no
errors have been introduced during data entry
an automatic check to make sure the data entered
has the correct number of characters

a check to make sure the data entered is sensible

a check to make sure the data entered is correct

[3]

3 A program checks that the data entered is between 1 and 100 inclusive.

Identify one piece of normal, extreme and erroneous test data for this program, and give a reason
for each.

Normal test data ...............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Extreme test data .............................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2021 0478/22/O/N/21 [Turn over


8

4 The pseudocode algorithm should work as a calculator and output the result.

1 Continue 1
2 WHILE Continue = 0
3 OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
4 INPUT Operator
5 OUTPUT "Enter the first value"
6 INPUT Value1
7 OUTPUT "Enter the second value"
8 OUTPUT Value2
9 IF Operator
10 1: Answer Value1 + Value2
11 2: Answer Value1 - Value2
12 3: Answer Value1 * Value2
13 4: Answer Value1 / Value2
14 ENDCASE
15 OUTPUT "The answer is ", Value1
16 OUTPUT "Do you wish to enter more values (Yes or No)?"
17 INPUT MoreValues
18 IF MoreValues = "No"
19 THEN
20 Continue 1
21 ENDIF
22 UNTIL Continue = 0

(a) Find the five errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 5 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[5]
© UCLES 2021 0478/22/O/N/21
9

(b) The algorithm needs changing to allow only the numbers 1, 2, 3, or 4 to be entered for the
input variable Operator.

Write the pseudocode to perform this task and state where in the algorithm it would be
located.

Pseudocode ..............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Location in algorithm ................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

© UCLES 2021 0478/22/O/N/21 [Turn over


10

5 The flowchart represents an algorithm.

The algorithm will terminate if –1 is entered at the List input.

START

List1 ←0
List2 ←0
INPUT
List

Yes IS
List = –1 ?

No

INPUT
Value

IS
List = 1 ?
Yes
List1 ← List1 + Value
No

IS
List = 2 ?
Yes
List2 ← List2 + Value
OUTPUT
"List 1 = ", List1
No

OUTPUT OUTPUT
"List 2 = ", List2 "Input Error"

IS Yes
List1 > List2 ?

No
OUTPUT
"List 1 is greatest"

OUTPUT
"List 2 is greatest"

END

© UCLES 2021 0478/22/O/N/21


11

Complete the trace table for the algorithm using this input data:

2, 77, 2, 16, 1, 35, 2, –7, 5, 18, 1, 11, 1, 12, 2, 20, –1, 18

List Value List1 List2 OUTPUT

[5]

© UCLES 2021 0478/22/O/N/21 [Turn over


12

6 A pet supplier uses the database table, STOCK, to keep records of its products for pets.

The fields are:

Field name Description


ProductID code to identify the product
ProductName name of product
ProductDescription information about the product
Animal type of animal the product is for, e.g. cat, bird, horse
ProductType type of product, e.g. food, toy, medicine
InStock whether the product is in stock or not

(a) (i) Identify the field that could have a Boolean data type.

..................................................................................................................................... [1]

(ii) Identify the field that should be used as the primary key.

..................................................................................................................................... [1]

(b) Complete the query-by-example grid to output the products intended for a cat that are in
stock. Display only the primary key and the name of the products. The output should be
sorted by the primary key.

Field:

Table:

Sort:

Show:

Criteria:

or:

[4]

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 2021 0478/22/O/N/21


Cambridge IGCSE™
* 4 6 5 7 1 8 1 0 8 7 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2021

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 16 pages. Any blank pages are indicated.

DC (CJ/SG) 202718/4
© UCLES 2021 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release material

A cruise ship has a speciality restaurant where tables can be booked for any of the three sessions:
lunch, early dinner or late dinner. A booking for a table can only be made on the day. There are
twenty tables available to book in the restaurant. Today’s date and how many tables are available for
lunch, early dinner and late dinner are displayed on a screen at the entrance to the restaurant.
Only one table can be booked at a time. When a booking is made, the name of the passenger making
the booking is recorded, together with their cabin number and any special dietary requirements.
Write and test a program or programs for a computer system to manage the daily restaurant bookings.
• 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 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 – at the start of the day


Write a program to set up the screen display at the start of the day showing the date and how many
tables are available for lunch, early dinner and late dinner. Bookings are to be stored in three separate
arrays: lunch, early dinner and late dinner. Initialise further arrays to record for each table booked: the
name of the passenger making the booking, their cabin number and any special dietary requirements.

Task 2 – making a table booking at the restaurant


Check if there is a table available for the session requested. If a table is available, record the
passenger’s name, cabin number and any special dietary requirements. Mark the table as booked
for that session. Display the name and cabin number for the passenger to check. Update the screen
display and mark a session as fully booked if all the tables are now booked.

Task 3 – special dietary requirements


The recording of special dietary requirements is confusing the restaurant staff. It has been decided
to use fixed options instead of a description. Only one option can be chosen for each booking.
The options are:
• gluten-free
• vegetarian
• vegan
• diabetic
• none.
Update Task 2 to allow for this.
Update Task 2 to count and display how many tables have vegetarian or vegan diners during the
day.
© UCLES 2021 0478/23/O/N/21
3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one constant that you could have used for Task 1. Give the value that would be
assigned to this constant. State the use of this constant.

Constant ...................................................................................................................................

Value .........................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[3]

(b) Describe the arrays that you have set up in Task 1 to record today’s data about the restaurant
tables.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/23/O/N/21 [Turn over


4

(c) Sometimes the restaurant has fewer tables available for a session.

Explain how you would change your Task 1 program to allow input of the number of tables
available for a session.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(d) Part of Task 2 is to check if a table is available. Write an algorithm to do this, using either
pseudocode, programming statements or a flowchart. Assume that Task 1 has been
completed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2021 0478/23/O/N/21
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 0478/23/O/N/21 [Turn over


6

(e) Explain how your program for Task 3 updated Task 2.

Include any programming statements used and fully explain the purpose of each statement.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 0478/23/O/N/21


7

Section B starts on Page 8.

© UCLES 2021 0478/23/O/N/21 [Turn over


8

Section B

2 An algorithm has been written in pseudocode to generate 50 positive random integers with values
less than or equal to 100. These numbers are stored in the array NumRand[]

The function RandUp(X,Y) generates a random integer greater than X and less than or equal to Y
For example, RandUp(1,4) generates 2 or 3 or 4

1 Count 0
2 WHILE Counter > 50 DO
3 NumRand[Counter] RandUp(1,100)
4 Counter Counter − 2
5 ENDWHILE

(a) Find the four errors in the pseudocode and write a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(b) The pseudocode for this algorithm could be shortened by the use of a FOR … NEXT loop.

Rewrite the algorithm using a FOR … NEXT loop.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2021 0478/23/O/N/21


9

3 A program has been written to check the length and content of a password. The password must be
eight or more characters long and contain at least one special character, for example, Secret!*!

(a) (i) State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.

Normal test data example .................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

Erroneous test data example ............................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................
[4]

(ii) Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(b) Describe two methods of verification that could be used to verify this data as it is input.

Method 1 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Method 2 ...................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/O/N/21 [Turn over


10

4 The algorithm, shown by this flowchart, allows the input of examination marks for a class of
students. A mark of 999 ends the process. If a mark is 40 or over then a pass grade is awarded.
The number of pass grades is calculated for the whole class. If this is under 50% of the class, the
class is offered extra help.

START

Counter 0
Pass 0

INPUT
Mark

IS Yes
Mark = 999 ? Help Pass / Counter

No
IS Yes
Counter Counter + 1 OUTPUT
Help < 0.5 ? "Extra Help"

No
Yes IS
Pass Pass + 1 Mark >= 40 ?
END
No

© UCLES 2021 0478/23/O/N/21


11

Complete a trace table for the algorithm using this input data:
88, 24, 60, 30, 44, 17, 25, 22, 54, 6, 999, −1

Counter Pass Mark Help OUTPUT

[5]

© UCLES 2021 0478/23/O/N/21 [Turn over


12

5 A database table, COMPUTER, is used to keep a record of computers available for sale.

The following data is stored for each computer:

• CATEGORY – desktop, laptop or tablet


• WEIGHT – weight in kilograms
• MANUFACTURER – ICN, Linoldo, Pear or JoeSing
• PRICE – price in $
• CODE – a unique code allocated by the manufacturer, e.g. P771
• STOCK – quantity in stock.

A database management system uses these data types:

Text Number Currency Boolean

The CATEGORY field and MANUFACTURER field have a data type of text.

(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.

WEIGHT data type ....................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

PRICE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

CODE data type .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

STOCK data type ......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2021 0478/23/O/N/21


13

(b) Complete the query-by-example grid to display only the category, manufacturer, price and
code of the computers with weight of less than 2.5 kilograms.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2021 0478/23/O/N/21


14

BLANK PAGE

© UCLES 2021 0478/23/O/N/21


15

BLANK PAGE

© UCLES 2021 0478/23/O/N/21


16

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 2021 0478/23/O/N/21


Cambridge IGCSE™
* 7 8 1 6 1 9 5 1 1 4 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming February/March 2022

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 16 pages. Any blank pages are indicated.

DC (CJ) 303924/3
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.
Pre-release material

A program is needed to record the number of strokes played by each player in a round of golf and
decide who is the winning player.
The object of the game of golf is to hit a small ball into a series of small holes using a golf club.
A score is kept of the number of times a player needs to hit the ball to get it in a hole; this is the
number of strokes for the hole. The total score for a round of golf is the total number of strokes taken
for each hole. The player with the least number of strokes is the winner.
A golf course consists of 9 or 18 holes. A round of golf is completed when all the holes have been
played. There can be 2, 3 or 4 players taking part in a round of golf. The number of strokes that
an experienced golfer would take to complete a round is called par. The scores for the round are
displayed in relation to the par score. For example, if par for an 18-hole course was 72, a score of 80
would be 8 over par and a score of 70 would be 2 under par.
Write and test a program or programs to score a round of golf:
• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 round
Each player’s scores for the round are to be stored in an array with a separate score for each hole.
The scores in these arrays are to be set to zero before a round starts.
The following data is to be input and stored:
• the number of players taking part in the round
• the names of the players
• the number of holes to be played: 9 or 18
• the par for the course.
The number of players, their names, the number of holes to be played and the par for the course are
all displayed to be checked before the round starts so that any errors seen can be corrected.
Task 2 – scoring the round
For each hole played, each player’s name is displayed on the screen and they are asked to enter
the number of strokes they played for that hole. Each player must enter the number of strokes twice
to verify their score. A player can choose to see the total number of strokes that they have played so
far in the round.
Task 3 – deciding the winning player
At the end of the round, display the name and final score for each player relative to par. The winner
is identified; display their name and the winning score. There are also options that display:
• every player’s score for each hole
• the player’s name and hole number of any score of one for a hole (hole-in-one)
• the average score for the round
• the average score for a hole.

© UCLES 2022 0478/22/F/M/22


3

1 All variables, constants and other identifiers must have meaningful names.

(a) State one constant and one variable that you could have used for Task 1. Give the value
that would be assigned to the constant. Give the data type for the variable. Explain why the
constant was used rather than a variable and explain why the variable was used rather than a
constant.

Constant name .........................................................................................................................

Value .........................................................................................................................................

Why a constant was used .........................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Variable name ...........................................................................................................................

Data type ..................................................................................................................................

Why a variable was used ..........................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

(b) Describe how your program set the scores to zero before each round for Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/F/M/22 [Turn over


4

(c) Write an algorithm for Task 2, using pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2022 0478/22/F/M/22


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/22/F/M/22 [Turn over


6

(d) Explain how your program completed part of Task 3 to identify the winner and to display their
name and the winning score relative to par. All programming statements that you include
must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/F/M/22


7

Section B starts on page 8

© UCLES 2022 0478/22/F/M/22 [Turn over


8

Section B

2 An algorithm has been written to:

• input the ages of 100 students


• count and output the number of students aged 7 and under 12
• count and output the number of students aged 12 and under 18
• count and output the number of students aged 18 and over.

(a) Complete the pseudocode algorithm:

01 Count7to12 0 ←
02 Count12to18 0 ←
03 CountOver18 0 ←
04 FOR Student ←
1 TO ............................................
05 OUTPUT "Please enter student's age in years "
06 INPUT Age
07 IF Age >= 7 ................................................
08 THEN
09 Count7to12 Count7to12 + 1 ←
10 ENDIF
11 IF Age >= 12 AND Age < 18
12 THEN
13 Count12to18 ←
.........................................
14 ENDIF
15 IF Age >= 18
16 THEN
17 CountOver18 CountOver18 + 1 ←
18 ENDIF
19 NEXT Student
20 OUTPUT "There are ", Count7to12, " students aged 7 and under 12."
21 OUTPUT "There are ", Count12to18, " students aged 12 and under 18."
22 OUTPUT "There are ", ................., " students aged 18 and over."
[4]

(b) Write the extra pseudocode statements that are needed to count and output the number of
students under the age of 7. Use the variable CountUnder7; assume CountUnder7 has
already been set to zero.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/F/M/22


9

3 Four validation checks and five descriptions are shown.

Draw a line from each validation check to the most appropriate description.

Validation check Description

checks that the data input is


between two values

length check

checks that the data input is


an integer

check digit

checks that the data input has


three digits

range check

checks that the data has


been input

type check

checks that the data input has


the correct digits
[4]

© UCLES 2022 0478/22/F/M/22 [Turn over


10

4 This flowchart inputs a whole number. The function INT returns the integer value of a number. For
example, INT (7.5) is 7

An input of -1 ends the routine.

START

INPUT Number

IS Number Yes
END
= –1?
No

C 0
D INT(Number/2)

IS
INT(Number/D) Yes
= Number/D?

No
C C + 1

D D – 1

No IS D =
1?

Yes

Yes IS C =
0?
No

OUTPUT C

© UCLES 2022 0478/22/F/M/22


11

(a) Complete the trace table for the given algorithm using this input data:
7, 6, 5, 4, –1, 12, 34

Number C D OUTPUT

[6]

(b) Describe the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) (i) Describe the problem that occurs if a whole number smaller than 4 and not equal to –1
is input.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Explain how to change the flowchart to prevent this problem occurring.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 0478/22/F/M/22 [Turn over
12

5 A database table, FLOWER, is used to keep a record of the type of flowers available to make up a
bouquet.

FlowerID Type Colour Style Fragrance


CN001 Carnation Pink Stem Y
CN002 Carnation Red Stem N
CN103 Carnation White Stem N
CN104 Carnation Yellow Stem Y
CN105 Carnation Pink Spray Y
CN106 Carnation Red Spray N
CN107 Carnation White Spray N
CN108 Carnation Yellow Spray Y
RE101 Rose Pink Stem Y
RE102 Rose Red Stem Y
RE103 Rose White Stem N
RE104 Rose Yellow Stem Y
RE105 Rose Orange Spray Y
RE106 Rose Peach Spray N
LY101 Lily White Spray Y

© UCLES 2022 0478/22/F/M/22


13

A query-by-example has been written to display just the type, style and colour of all flowers that
have no fragrance.

Field: FlowerID Fragrance Style Colour

Table: FLOWER FLOWER FLOWER FLOWER

Sort:

Show: 3 3 3 3

Criteria: =Y

or:

Explain why the query-by-example is incorrect and write a correct query-by-example.

Explanation ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Field:

Table:

Sort:

Show:

Criteria:

or:
[6]

© UCLES 2022 0478/22/F/M/22


14

BLANK PAGE

© UCLES 2022 0478/22/F/M/22


15

BLANK PAGE

© UCLES 2022 0478/22/F/M/22


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/22/F/M/22


Cambridge IGCSE™
* 3 0 6 2 8 7 9 6 9 6 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2022

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.

DC (KN) 303743/3
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release material

Friends of Seaview Pier is an organisation devoted to the restoration and upkeep of a pier in the
town. A pier is a wooden structure that provides a walkway over the sea. The pier requires regular
maintenance and the friends of the pier need to raise money for this purpose.
Members of Friends of Seaview Pier each pay $75 per year, as a contribution to the pier’s running costs.
This entitles them to free admission to the pier throughout the year. They can also volunteer to help run
the pier, by working at the pier entrance gate, working in the gift shop, or painting and decorating.
To provide additional income, the pier’s wooden planks can be sponsored. A brass plaque, which
contains a short message of the sponsor’s choice, is fitted to a plank on the pier, for a donation of
$200.
Write and test a program or programs for the Friends of Seaview Pier:
• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 – becoming a member of Friends of Seaview Pier
Set up a system to enable people to become members of Friends of Seaview Pier and for each new
member enter:
• their first name and last name
• whether or not they wish to work as a volunteer
○ if they choose to volunteer, identify the area from:
– the pier entrance gate
– the gift shop
– painting and decorating
• the date of joining
• whether or not they have paid the $75 fee.
All of this information needs to be stored using suitable data structures.
Task 2 – using the membership data
Extend the program in Task 1 so that a list of the first and last names of members can be output in
any of the following categories:
• Members who have chosen to work as volunteers.
• Volunteers who would like to work at the pier entrance gate.
• Volunteers who would like to work in the gift shop.
• Volunteers who would like to help with painting and decorating tasks.
• Members whose membership has expired (they have not re-joined this year).
• Members who have not yet paid their $75 fee.
Task 3 – sponsoring a wooden plank
Add an additional option to the program in Task 1 to enable the pier’s wooden planks to be
sponsored. Separate data structures should be used to store the names of the individuals and
the short messages they would like to have written on their brass plaque. An output would display
everything that was input for the sponsor to confirm. If errors are found, the program should allow
data to be re-entered. Once complete, the data is stored and the sponsor is charged $200.

© UCLES 2022 0478/21/M/J/22


3

1 (a) Describe the data structures you could have used in Task 1. Your description should include
types of data structure, names used for data structures, their uses and examples of sample
data.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

(b) Explain how you could change your program in Task 1 to total all the money collected from
new members who have paid.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Describe how data input in Task 1 could be validated to find out if a new member wants to
work as a volunteer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/M/J/22 [Turn over


4

(d) Write an algorithm to show how your program completes Task 3 assuming the option to
sponsor a wooden plank has been chosen, using pseudocode, programming statements or a
flowchart. Details completed in Task 1 are not required.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

© UCLES 2022 0478/21/M/J/22


5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]
© UCLES 2022 0478/21/M/J/22 [Turn over
6

(e) Explain how your program allows any one of the member or volunteer lists to be selected and
displayed (part of Task 2). Any programming statements used in your answer must be fully
explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/21/M/J/22


7

Section B

2 Tick (ü) one box in each row to identify the most appropriate data type for each description. Only
one tick (ü) per column.

Data type
Description
Boolean Char Integer Real String
a single character from the keyboard

multiple characters from the keyboard

only one of two possible values

only whole numbers

any number
[4]

3 Give one piece of normal test data and one piece of erroneous test data that could be used to
validate the input of an email address.

State the reason for your choice in each case.

Normal test data ...............................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Erroneous test data ..........................................................................................................................

..........................................................................................................................................................

Reason .............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/21/M/J/22 [Turn over


8

4 The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.

(a) Complete this flowchart:

START

PassCount 0

FailCount 0

Count 0

Yes No

Count Count + 1

No

Yes

END

[6]
© UCLES 2022 0478/21/M/J/22
9

(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/21/M/J/22 [Turn over


10

5 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division.
For example, R = 9 MOD 4 gives the value R = 1

First ← 0
Last ←
0
INPUT Limit
FOR Counter ← 1 TO Limit
INPUT Value
IF Value >= 100
THEN
IF Value < 1000
THEN
First ← Value DIV 100
Last ←Value MOD 10
IF First = Last
THEN
OUTPUT Value
ENDIF
ENDIF
ENDIF
NEXT Counter

(a) Complete the trace table for the algorithm using this input data:

8, 66, 606, 6226, 8448, 642, 747, 77, 121

Counter Value First Last Limit OUTPUT

[5]

© UCLES 2022 0478/21/M/J/22


11

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/21/M/J/22 [Turn over


12

6 A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.

Name Description
GameID primary key
GameName the name of each game
AgeRestriction the minimum age at which a person is allowed to play each game
GamePrice the selling price for each game
NumberStock the quantity of each game currently in stock
OnOrder whether or not each game is on order from the suppliers
DateLastOrdered the date the most recent order for each game was placed
GameDescription a summary of the contents and purpose of each game

(a) State the number of fields that are in the table GAMES.

............................................................................................................................................. [1]

(b) State one important fact that must be true for a field to be a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Complete the query-by-example grid to output all the games that have no stock and that are
on order with the supplier. Display only the GameID, GameName and GamePrice fields in
alphabetical order of the name of the game.

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/21/M/J/22


Cambridge IGCSE™
* 6 5 6 8 1 1 8 8 5 0 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming May/June 2022

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.

DC (PQ) 303914/4
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release material
A program is needed to allow a Wildlife Park to sell tickets. A booking consists of one or more tickets for
the same day(s) and can be made up to a week in advance. A booking can be made for a visit of one day
or two consecutive days. A booking can have extra attractions included. A booking will be valid for the
day(s) chosen only.

Ticket type Cost for one day Cost for two days
one adult $20.00 $30.00
one child (an adult may bring up to two children) $12.00 $18.00
one senior $16.00 $24.00
family ticket (up to two adults or seniors, and three children) $60.00 $90.00
groups of six people or more, price per person $15.00 $22.50

Extra attraction Cost per person


lion feeding $2.50
penguin feeding $2.00
evening barbecue (two-day tickets only) $5.00

Write and test a program or programs for the Wildlife Park:


• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 – displaying the ticket options and the extra attractions available
Set up your program to:
• display the options, attractions and prices for one-day tickets
• display the options, attractions and prices for two-day tickets
• show the days available for booking; assume that there are tickets available for any valid day.

Task 2 – process a booking


Extend your program for Task 1 to:
• input the tickets and extra attractions required, then calculate the total cost of the booking
• allocate a unique booking number
• display the booking details, including the total cost and the unique booking number
• repeat as required.

Task 3 – ensuring each booking is the best value


Check that the total for each booking gives the best value and offer an alternative if this is not the case.
For example, buying two family tickets is better than a group ticket for a group of 10 that includes
four adults and six children.
© UCLES 2022 0478/22/M/J/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant that you could have used for Task 1.
Give the value and use of the constant.

Constant ............................................................................................................................

Value .................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[3]

(ii) Identify one variable that you could have used for Task 2.
Give the data type and use of the variable.

Variable .............................................................................................................................

Data type ...........................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................
[3]

(b) Explain how your program showed the days available for booking in Task 1.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Explain how your program made sure that each booking number allocated in Task 2 was
unique.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/22/M/J/22 [Turn over


4

(d) Write an algorithm for the part of Task 2 that inputs the tickets and extra attractions required
then calculates the total cost of the booking.

Assume that the booking is for a single day.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/22/M/J/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/22/M/J/22 [Turn over


6

(e) Explain how your program decides when a family ticket is better value in Task 3.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/22/M/J/22


7

Section B starts on page 8

© UCLES 2022 0478/22/M/J/22 [Turn over


8

Section B

2 An algorithm allows a user to input their password and checks that there are at least eight
characters in the password. Then, the user is asked to re-input the password to check that both
inputs are the same. The user is allowed three attempts at inputting a password of the correct
length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of
characters in the string, X

01 Attempt 0 ←
02 REPEAT
03 PassCheck TRUE ←
04 OUTPUT "Please enter your password "
05 INPUT Password
06 IF LEN(Password) < 8
07 THEN
08 PassCheck TRUE ←
09 ELSE
10 OUTPUT "Please re-enter your password "
11 INPUT Password2
12 IF Password <> Password
13 THEN
14 PassCheck FALSE ←
15 ENDIF
16 ENDIF
17 Attempt ←
Attempt + 1
18 UNTIL PassCheck OR Attempt <> 3
19 IF PassCheck
20 THEN
21 OUTPUT "Password success"
22 ELSE
23 OUTPUT "Password fail"
24 ENDIF

(a) Identify the three errors in the pseudocode and suggest a correction to remove each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................
[3]

© UCLES 2022 0478/22/M/J/22


9

(b) The algorithm includes two types of check on the data input.
Identify and describe each type of check.

Type of check 1 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................

Type of check 2 ........................................................................................................................

Description ................................................................................................................................

...................................................................................................................................................
[4]

(c) Give two sets of test data for this algorithm and a reason for choosing each set.

Each set of test data and its reason must be different.

Set 1 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

3 (a) Describe a one-dimensional array. Include an example of an array declaration.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Explain how indexing could be used to search for a value stored in a one-dimensional array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/22/M/J/22 [Turn over


10

4 This algorithm checks the temperature of hot food being served to customers.
Error

START

Counter 0
Hot 0
Cold 0
Serve 0

INPUT Temp

Is Temp Yes Error


= –1? ((Hot + Cold) / Counter) * 100

No

Is Temp Yes OUTPUT


Hot Hot + 1
> 86? "Too Hot"

Counter No
Counter + 1 OUTPUT
Error
Is Temp Yes
Cold Cold + 1
< 63?
No
OUTPUT
Serve Serve + 1 "Too Cold"
END

© UCLES 2022 0478/22/M/J/22


11

(a) Complete the trace table for the algorithm using this input data:

75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20

Counter Hot Cold Serve Temp Error OUTPUT

[7]

(b) State how the final output from the algorithm could be improved.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Identify the process in the algorithm that is not required.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2022 0478/22/M/J/22 [Turn over


12

5 A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.

This is part of the table:

ItemNumber Description SingleUse Uses StockLevel ReorderLevel

DIG1 Glove (pair) Y 1 500 800

DIA1 Apron Y 1 700 800

DIM5 Hair net Y 1 650 500

DIA2 Apron N 5 25 100

DIS4 Suit N 3 70 50

DIV9 Shoe cover (pair) Y 1 400 250

(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]

(b) Give a reason why the field SingleUse is not required in the table NURSE.

...................................................................................................................................................

............................................................................................................................................. [1]

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/22/M/J/22


Cambridge IGCSE™
* 8 1 1 3 9 3 2 4 8 5 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming May/June 2022

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. Any blank pages are indicated.

DC (CJ) 303921/2
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.
Pre-release material

Seaview Castle Visitor Centre is open seven days a week. It offers a range of facilities and activities
including meeting rooms, a permanent fossil exhibition, supervised walks along the cliff tops and an
old stone quarry.
There are three meeting rooms, which can each be booked separately. There is one large room
that can be used for a variety of activities such as showing films, holding presentations, displaying
exhibitions or wedding receptions. There are also two smaller meeting rooms. Each room can be
booked by the day according to the following tariff:

Room Cost per day


large $295
small 1 $175
small 2 $150

Write and test a program or programs to arrange meeting room bookings:


• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 a booking system structure for the meeting rooms
Set up suitable data structures for each of the three meeting rooms to store:
• when it is booked during a fixed eight-week period
• the client’s name (the person making the booking)
• a unique booking code
• the cost of the booking.
Task 2 – booking a meeting room
Extend the program in Task 1 to enable bookings to be made so that the client enters their name,
the meeting room required and the day of the booking. After the data has been entered, the program
should check if the requested day is available for the required meeting room and if not, the client
should be allowed to enter an alternative day or exit the program.
If the requested day is available, the booking details and cost of the booking should be output for
the client to confirm. Once confirmed, a unique booking code should be generated and stored in
both the appropriate meeting room data structure and the unique booking code data structure. The
client’s name and cost of the booking should be stored in the appropriate data structures set up in
Task 1.
Bookings of more than one day must be entered as separate single day bookings.
Task 3 – using the booking data
Extend the program in Task 1 and Task 2 to make use of the data that is available, to:
• select a meeting room and output the days when it is free
• total and output the amount of money currently taken for all three meeting rooms
• check the bookings for a specific client.
© UCLES 2022 0478/23/M/J/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) Identify one variable and one array you could have used for Task 1 or Task 2.

Give the use for the variable and array.

Variable .....................................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Array .........................................................................................................................................

Use ...........................................................................................................................................

............................................................................................................................................. [4]

(b) Describe how you could test if the validation of the input to choose a meeting room works
(Task 2).

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) Explain how your program in Task 2 could be altered to allow a 30% discount on bookings for
the same meeting room of two to six days, inclusive.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/23/M/J/22 [Turn over


4

(d) Write an algorithm to show how your program completes the following parts of Task 2:

• output the booking details and cost of the booking


• take confirmation from the client
• generate a unique booking code
• store the booking details.

Assume that Task 1 and the first part of Task 2 have been completed.

Assume that the booking is for a single day and that the requested booking day is available.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/23/M/J/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2022 0478/23/M/J/22 [Turn over
6

(e) Explain how your program selects a meeting room, finds and then outputs the days when it
is available (part of Task 3). Any programming statements used in your answer must be fully
explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/23/M/J/22


7

Section B

2 Tick (3) one or more boxes in each row to match the type(s) of test data to each description.

Types of test data


Description Erroneous /
Boundary Extreme Normal
Abnormal

test data that is always on the limit of


acceptability

test data that is either on the limit of


acceptability or test data that is just
outside the limit of acceptability

test data that will always be rejected

test data that is within the limits of


acceptability

[4]

3 Describe what is meant by the terms variable and constant and give an example of each in your
answer.

Variable ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Constant ...........................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2022 0478/23/M/J/22 [Turn over


8

4 The pseudocode represents an algorithm.

The pre-defined function DIV gives the value of the result of integer division.
For example, Y = 11 DIV 4 gives the value Y = 2

Count ←0
INPUT Limit
FOR In ←

1 TO Limit
Logic

TRUE
Test 2
INPUT Number
REPEAT
IF Number / Test = Number DIV Test


THEN
Logic FALSE
ELSE
Test ←Test + 1
ENDIF
UNTIL NOT Logic OR Test >= Number DIV 2
IF Logic


THEN


Store[Count] Number
Count Count + 1
ENDIF
NEXT In
FOR Out ←
0 TO Count - 1
OUTPUT Store[Out]
NEXT Out

(a) Complete the trace table for the algorithm using this input data:
5, 9, 5, 8, 10, 7

Store
In Logic Test Number Count Limit Out OUTPUT
[Count]

[7]
© UCLES 2022 0478/23/M/J/22
9

(b) State the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) This algorithm only works for numbers that are 3 or greater.

Describe how you could change this algorithm to make sure that only numbers that are
3 or greater are entered. Any pseudocode statements used in your answer must be fully
described.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/M/J/22 [Turn over


10

5 The flowchart shows an algorithm that should:


• allow 100 numbers to be entered into the variable Number
• total the numbers as they are entered
• output the total and average of the numbers after they have all been entered.

Complete this flowchart:

START

Total 0

Counter 0

No

Yes

END
[6]
© UCLES 2022 0478/23/M/J/22
11

6 Data about planets in the solar system is stored in a database table called PLANETS. The fields
used in the table are shown.

Name of field Contents of field


PlanetName the name of the planet
PlanetMass the planet’s mass in kilograms
Larger whether or not the planet has a greater mass than Earth
MaxDistance the maximum distance the planet is from Earth in kilometres
MinDistance the minimum distance the planet is from Earth in kilometres
YearLength the length of time it takes for the planet to orbit the Sun in Earth days

(a) State the name of the field that could contain Boolean data.

............................................................................................................................................. [1]

(b) Complete the query-by-example grid to output the planets with a longer year length and
greater mass than Earth. Assume Earth’s year length is 365 days.

Display only the name of the planets sorted in alphabetical order.

Field:

Table:

Sort:

Show: o o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/23/M/J/22


12

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/23/M/J/22


Cambridge IGCSE™
* 0 6 7 5 1 6 4 9 9 2 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming October/November 2022

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 16 pages. Any blank pages are indicated.

DC (NF) 303968/3
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release Material

A program is needed for a swimming club to manage the annual audit of its membership details.

The data stored about each member includes name, age, gender, type of membership, whether
a team member or not, annual fee and if the fee has been paid. Team members are allowed a
discount of 10% on their annual membership fee.

The types of membership available are:

Membership Age range in years Annual fee


junior >= 2 and < 18 $10.00
adult >= 18 and < 50 $20.00
senior >= 50 and < 80 $15.00
golden 80 and over free

Write and test a program or programs for the swimming club annual audit:

• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 store the membership details

Set up your program to:


• store the members’ details in arrays
• populate the arrays with at least 20 members’ details
• use the array index as the annual membership number.

Task 2 – providing annual audit statistics

Count the number of current members by membership type. For each type of membership count the
number of members who did not pay the annual fee. Display these counts as a percentage of the
total number of members for each membership type. Calculate and display the total of the annual
fees expected and the annual fees received for this year.

Task 3 – updating the membership details for the next year

Extend your program to:


• check if any members have not paid and output a list of all these members
• remove these members from the system
• update the age of all the members by one year and whether they are in a team
• update the type of membership and the annual fee if required
• set the fee for every member as not yet paid
• display lists of current team members grouped by membership type.

© UCLES 2022 0478/21/O/N/22


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Describe the arrays you have set up in Task 1 to record the members’ details. Include in
your description the name, data type and sample data for each array.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(ii) Explain how your program for Task 1 populated the arrays with the members’ details.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(b) Explain how your program removed the members that have not paid their fees from the
system in Task 3.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2022 0478/21/O/N/22 [Turn over


4

(c) Write an algorithm for the part of Task 3 that checks the age of all the members, and whether
they are in a team, then updates the type of membership and the annual fee if required.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/21/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/21/O/N/22 [Turn over


6

(d) Explain how your program completes these parts of Task 2:

• Count the number of members of each membership type who did not pay the annual
fee.
• Display these counts as a percentage of the total number of members for each
membership type.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2022 0478/21/O/N/22


7

Section B starts on page 8.

© UCLES 2022 0478/21/O/N/22 [Turn over


8

Section B

2 An algorithm has been written to:

• set 100 elements of the array Reading[1:100] to zero


• input integer values between 1 and 100
• end the process with an input of –1
• reject all other values
• count and output the number of times each value is input, starting with the largest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

O2 Reading[Count] 0

03 NEXT Count

04 OUTPUT "Please enter next reading "

05 INPUT Value

06 WHILE Value <> -1 DO

07 IF Value <= 0 OR .................................................................................................

08 THEN

09 OUTPUT "Reading out of range"

10 ELSE

11 Reading[Value] .......................................................................................

12 ENDIF

13 OUTPUT "Please enter next reading "

14 ......................................................................................................................................

15 ENDWHILE

16 Count 100

17 REPEAT

18 OUTPUT "There are ", .............................................................................,


" readings of ", Count

19 Count ...................................................................................................................

20 UNTIL Count = 0
[6]

© UCLES 2022 0478/21/O/N/22


9

(b) Describe how the algorithm could be changed so that it does not output any counts of zero.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


10

3 (a) A PIN (personal identification number) is input into a banking app by the user. Before the PIN
is accepted, the following validation checks are performed:

• check 1 – each character must be a digit


• check 2 – there must be exactly four digits
• check 3 – the value of the PIN must be between 1000 and 9999 inclusive.

Describe each validation check.

Check 1 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 2 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Check 3 ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

(b) The PIN can be changed by the user.

Describe how the new PIN could be verified before use.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22


11

Question 4 starts on page 12.

© UCLES 2022 0478/21/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough fresh bread rolls available for customers to buy.

START

Stock 50
Total 0

INPUT Sold

Yes
IS Sold = OUTPUT Total
–1?

No
STOP
Stock Stock – Sold

Yes OUTPUT
IS Stock
< 20? "Add new stock"

No

Total Total + Sold Stock Stock + 50

© UCLES 2022 0478/21/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:
24, 12, 6, 30, 12, 18, –1, 24

Sold Stock Total OUTPUT

[4]

(b) Identify the problem that will occur if the input data starts with a value of 70.
Explain how you would correct this problem.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/21/O/N/22 [Turn over


14

5 A database table, WAREHOUSE, is used to keep a record of items for sale. The table has these
fields:

• ItemCode – code to identify each type of item


• Description – brief description of each item
• Manufacturer – name of manufacturer
• Level – number in stock
• Price – price in dollars ($).

(a) State which field you would choose for the primary key. Give a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the item code and the manufacturer
where the number in stock is below 10.

Field:

Table:

Sort:

Show: o o o o
Criteria:

or:
[3]

© UCLES 2022 0478/21/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/21/O/N/22


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/21/O/N/22


Cambridge IGCSE™
* 6 4 3 7 4 4 2 5 4 7 *

COMPUTER SCIENCE 0478/22


Paper 2 Problem-solving and Programming October/November 2022

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 16 pages. Any blank pages are indicated.

DC (CJ/CB) 303988/3
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.

Pre-release Material

An organisation has a visitor car park with 20 car parking spaces numbered 1 to 20. Car park
spaces can be booked by visitors up to two weeks before the date they are needed, as long as a
space is available. Visitors request a car parking space by stating the day in the two-week period in
which it is required. They give the licence number of the car to be parked and their name. The next
available space, beginning at space 1, is allocated and the given data and booking are stored. A
system is required to record the car park bookings.
Write and test a program or programs for the visitor car park booking system to work for a static
period of two weeks:
• Your program or programs must include appropriate prompts for the entry of data. Data must
be validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 booking system
Set up suitable data structures to store the car licence numbers and names of visitors who have
booked car parking spaces. The data structures should have sufficient capacity to store data for
each of the 20 parking spaces for a static period of two weeks. Allow a visitor to request a parking
space on any day within the two-week period by entering a number between 1 and 14, inclusive.
The system will check that there are spaces available on the day requested, and if so, will ask the
visitor to enter their name and car licence number. This data will be stored in the data structures
representing the first available parking space for the day requested. The visitor will be told the
number of their parking space.
At the end of the two-week period, allow all of the data to be deleted ready for the next two-week
period.
Task 2 – adding accessible parking spaces
The visitor car park booking system is to be re-designed to offer accessible parking. Spaces 1 to 5
are named accessible spaces. Spaces 6 to 20 are named general spaces.
Extend your program in Task 1 so that:
• when a visitor requests a parking space, they are additionally asked if they need an accessible
space
• if so, they are allocated the first available space beginning at space 1 and finishing at
space 20
• if not, they are allocated the first available space beginning at space 20 and finishing at
space 6.
The system must work so that visitors requiring accessible parking may be allocated any of the
20 spaces, but visitors who do not need accessible parking may only be allocated general spaces.
Task 3 – working out car park usage statistics
Extend the program to enable the following statistics to be counted and output on request:
• The number of accessible spaces used on any of the 14 days.
• The number of general spaces used on any of the 14 days.
• The total number of spaces used on any of the 14 days.
• The number of accessible spaces used in the whole 14-day period.
• The number of general spaces used in the whole 14-day period.
• The total number of spaces used in the whole 14-day period.
© UCLES 2022 0478/22/O/N/22
3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant you could have used for Task 1 and state its value.

Constant ............................................................................................................................

Value .................................................................................................................................
[2]

(ii) Identify one array you could have used in Task 1 and describe its use.

Array ..................................................................................................................................

Use ....................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[2]

(b) Describe how your program could validate the input for the day number within the two-week
period to make sure an appropriate value is entered (part of Task 1).

You must include programming statements as part of your answer.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/22/O/N/22 [Turn over


4

(c) Write an algorithm to show how your program allocates a parking space if the visitor requires
accessible parking (part of Task 2), including all relevant input and output, using pseudocode,
programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/22/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2022 0478/22/O/N/22 [Turn over


6

(d) Explain how your program in Task 2 could be altered so that bookings can be made for
any time over a four-week period instead of the current two-week period. Any programming
statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(e) Explain how your program records and outputs the number of accessible and general parking
spaces used for the two-week period (part of Task 3). Any programming statements used in
your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2022 0478/22/O/N/22
7

Section B

2 Draw a line to connect each programming concept to the most appropriate description.

Programming concept Description

carrying out an action multiple times within a loop


structure

counting

adding together the numbers in a list of numbers


repetition

tracking the number of iterations a program has


selection performed in a loop

sequence
branching off to take a course of action depending
on the answer to a question

totalling

a set of statements to be executed in order

[4]

3 Describe the use of verification on input of data when entering a list of items in stock into a
database. Explain why verification is necessary.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

4 Describe one type of test data that must be used to test if a program accepts valid input data.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [2]

© UCLES 2022 0478/22/O/N/22 [Turn over


8

5 This pseudocode should allow 500 marks to be entered into the algorithm. If the mark is 80 or
greater it is stored in an array for higher marks. If the mark is less than 80, but greater than or
equal to 50 it is stored in an array for middle marks. The remaining marks are stored in an array
for lower marks. The results from the algorithm are displayed at the end.

01 HighList 0
02 MidList 0
03 LowList 0
04 MarksEntry 0
05 REPEAT
06 INPUT Mark
07 IF Mark >= 80
08 THEN
09 Higher[HighList] MarksEntry
10 HighList HighList + 1
11 ELSE
12 IF Mark >= 50
13 THEN
14 Middle[MidList] Mark
15 MidList MidList
16 ELSE
17 Lower[HighList] Mark
18 LowList LowList + 1
19 ENDIF
20 ENDIF
21 MarksEntry MarksEntry + 1
22 NEXT MarksEntry = 500
23 OUTPUT "You entered ", HighList, " higher marks"
24 OUTPUT "You entered ", MidList, " middle marks"
25 OUTPUT "You entered ", LowList, " lower marks"

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]
© UCLES 2022 0478/22/O/N/22
9

(b) The corrected algorithm needs to be changed so that any number of marks may be entered
and the algorithm runs until the user tells it to stop.

Write the new pseudocode statements that would be needed to achieve this and state where
in the algorithm they would be placed.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2022 0478/22/O/N/22 [Turn over


10

6 This flowchart represents an algorithm to divide three-digit numbers into hundreds, tens and units.

The pre-defined function DIV gives the value of the result of integer division, for example
Y = 9 DIV 4 gives the value Y = 2

The pre-defined function MOD gives the value of the remainder of integer division, for example
R = 9 MOD 4 gives the value R = 1

START

Counter 0

Counter Counter + 1

Yes IS
Counter > 7?

No

INPUT
Number

IS Yes
Number < 100?

No

IS Yes
Number > 999?

No

Hundreds Number DIV 100

Temp Number MOD 100

Tens Temp DIV 10

Units Number MOD 10


STOP

OUTPUT "Hundreds: ",


Hundreds, " Tens: ",
Tens, " Units: ", Units

© UCLES 2022 0478/22/O/N/22


11

Complete the trace table for the algorithm using this input data:

97, 876, 4320, 606, 9875, 42, 124

Counter Number Hundreds Temp Tens Units OUTPUT

[5]

© UCLES 2022 0478/22/O/N/22 [Turn over


12

7 A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in its curriculum.

SubjectCode SubjectName Exams Practicals Candidates


COMP Computer Science 2 1 200
INFO Information Technology 1 2 200
MATH Mathematics 3 0 350
PHYS Physics 2 1 120
CHEM Chemistry 2 1 120
BIOL Biology 2 1 200
GEOG Geography 2 0 200
HIST History 2 0 250
GEOL Geology 2 0 80
PHED Physical Education 1 2 350
FREN French 2 2 120
ENGL English 2 2 350

This database only allows the data types:


• text
• number
• currency
• Boolean.

(a) (i) State the most appropriate data type for the fields SubjectCode and Exams.

SubjectCode ......................................................................................................................

Exams ...............................................................................................................................
[1]
(ii) State one reason why the Candidates field could not be of the Boolean data type.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2022 0478/22/O/N/22


13

(b) Show the output given by the query-by-example grid.

Field: SubjectName Practicals Candidates

Table: ASSESS ASSESS ASSESS

Sort: Ascending

Show: 3 3

Criteria: <1

or:

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(c) Complete the query-by-example grid to output the subjects with fewer than 150 candidates.
Display only the SubjectCode, SubjectName and Candidates fields in order of the number of
candidates from largest to smallest.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/22/O/N/22


14

BLANK PAGE

© UCLES 2022 0478/22/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/22/O/N/22


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/22/O/N/22


Cambridge IGCSE™
* 1 6 4 9 5 4 6 1 5 9 *

COMPUTER SCIENCE 0478/23


Paper 2 Problem-solving and Programming October/November 2022

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 16 pages. Any blank pages are indicated.

DC (LK/CB) 303980/4
© UCLES 2022 [Turn over
2

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 following tasks before the
examination to answer Question 1.
Pre-release Material
A program is needed for a window cleaning company to store details of the services provided to their
customers for each cleaning job.
The data stored will be used to show the customers exactly what services they are paying for
(provide an itemised bill). The data will allow the company to find out which services are used most
often and least often.
The services available to customers are:
Service Cost
basic window clean outside, only one floor, up to five windows $10.00
additional windows up to and including five $5.00
two floors 10% extra
three floors 15% extra
inside as well 25% extra
polish all windows cleaned 5% extra
special solar panel clean $20.00
The total cost of the customer’s bill is calculated in the same order as the rows of the table.
For example, a customer who has six windows over three floors is charged $10 + $5 with 15% extra,
giving a total bill of $17.25.
Write and test a program or programs for the window cleaning company:
• Your program or programs must include appropriate prompts for the entry of data. Data must be
validated on entry.
• All outputs, including error messages, need to be set out clearly and understandably.
• All 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 store the customer and service details
Set up your program to:
• store a customer name and address in a single dimensional array at the next position
• use the array index of this position as the unique number of the itemised bill
• store any service required at the same position in the appropriate service array; use an array for
each service.
Task 2 – storing the services for a customer and displaying the itemised bill
Extend your program to:
• display the services and the cost of each one
• input and store a customer’s details and the services they require
• calculate the total cost
• display the itemised bill including the total cost and the unique number of the bill
• repeat as required.
Task 3 – providing statistics about the services
Excluding the basic window clean and the additional windows, find the most popular service and
the least popular service. For these two services, display the service name, whether it was the most
or least popular and the number of times each service was used as a percentage of the total bills
stored.

© UCLES 2022 0478/23/O/N/22


3

1 All variables, constants and other identifiers must have meaningful names.

(a) (i) Identify one constant that you could have used for Task 1.

State the value that would be assigned to the constant.

Give a reason why a constant was used rather than a variable.

Constant name ..................................................................................................................

Value .................................................................................................................................

Reason ..............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[3]

(ii) Describe the array that you set up in Task 1 to record the customer details.

Include the name, data type and sample data for the array in your description.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(b) Explain how your program allowed only two floors or three floors to be chosen but not both.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


4

(c) Write an algorithm for the part of Task 2 that calculates the total cost of the bill.
Assume that the customer details and services required have already been input.

Use pseudocode, programming statements or a flowchart.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
© UCLES 2022 0478/23/O/N/22
5

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]
© UCLES 2022 0478/23/O/N/22 [Turn over
6

(d) Explain how your program completed Task 3.

Any programming statements that you include in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2022 0478/23/O/N/22


7

Section B starts on page 8.

© UCLES 2022 0478/23/O/N/22 [Turn over


8

Section B

2 An algorithm has been written to:


• set all 50 elements of the array Reading[1:50] to zero
• input values between 35 and 50 inclusive
• end the process when an input of –1 is made or 50 valid numbers have been entered
• reject all other values
• count the number of times each valid value is input
• output the number of times each value has been input, starting with the lowest value.

(a) Complete the pseudocode algorithm:

01 FOR Count 1 TO ....................................................................................................

02 Reading[Count] 0

03 NEXT Count

04 Count 1

05 OUTPUT "Please enter next reading "

06 INPUT Value

07 REPEAT

08 IF Value < 35 OR .................................................................................................

09 THEN

10 OUTPUT "Reading out of range"

11 ELSE

12 Reading[Value] .......................................................................................

13 Count = Count + 1

14 ENDIF

15 IF Count <= 50

16 THEN

17 OUTPUT "Please enter next reading "

18 .................................................................................................................................

19 ENDIF

20 UNTIL Value = -1 OR Count > 50

21 Count 35

22 REPEAT

23 OUTPUT "There are ", .....................................................................,


" readings of ", Count

24 Count ...................................................................................................................

25 UNTIL Count > 50 [6]


© UCLES 2022 0478/23/O/N/22
9

(b) Describe how the algorithm could be changed to output the number of times each value has
been input, starting with the highest value.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


10

3 A check digit is to be used to validate an identification number on input. The identification number
contains five digits and the check digit.
The check digit is calculated by adding up the first five digits, dividing by 10 and taking the
remainder.
For example, 5 + 1 + 2 + 4 + 3 divided by 10 gives a remainder of 5 so the six-digit
identification number would be 512435

(a) (i) Calculate the check digit for 69321

...........................................................................................................................................

..................................................................................................................................... [1]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(ii) State which of these identification numbers have incorrect check digits.

A 123455
B 691400
C 722855
D 231200

...........................................................................................................................................

..................................................................................................................................... [2]

Working space ...................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

(b) (i) Describe an input error that would not be found using this check digit.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Describe a more suitable algorithm to calculate the check digit for this identification
number.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2022 0478/23/O/N/22
11

(c) Identify two other validation checks that could be used when inputting this identification
number.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2022 0478/23/O/N/22 [Turn over


12

4 This algorithm makes sure that there are enough wheelbarrows in stock.

START

Stock 10
Total 0

INPUT Sale

Yes
Is Sale = OUTPUT Total
"N"?

No
STOP
Stock Stock – 1

Yes OUTPUT
Is Stock
< 5? "Add new stock"

No

Total Total + 1 Stock Stock + 10

© UCLES 2022 0478/23/O/N/22


13

(a) Complete the trace table for the algorithm using this input data:

“Y”, “Y”, “Y”, “Y”, “Y”, “Y”, “N”

Stock Total Sale OUTPUT

[4]

(b) Explain how you could extend the algorithm to allow for the sale of more than one wheelbarrow
at a time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2022 0478/23/O/N/22 [Turn over


14

5 A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
• ItemCode – code for each type of item, for example ART0005
• Description – brief description of each item, for example gold coin
• InStore – whether the item is in store or not, for example Y
• Century – century when item made, for example 18
• Country – country of origin, for example China.

(a) Identify which field you would choose for the primary key.

State a reason for your choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the query-by-example grid to display only the description and the country of origin
for those items not in store.

Field:

Table:

Sort:

Show:

Criteria:

or:
[3]

© UCLES 2022 0478/23/O/N/22


15

BLANK PAGE

© UCLES 2022 0478/23/O/N/22


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2022 0478/23/O/N/22


Cambridge IGCSE™
* 2 8 3 1 0 1 3 0 1 6 *

COMPUTER SCIENCE 0478/22


Paper 2 Algorithms, Programming and Logic February/March 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (LK/SG) 334324/4
© UCLES 2023 [Turn over
2

1 Tick (3) one box to show which word accurately describes the scope of a variable declared in a
procedure.

A Function

B Global

C Local

D Subroutine
[1]

2 (a) Four descriptions and five pseudocode statements are shown.

Draw one line to link each description to its most appropriate pseudocode statement.
Not all pseudocode statements will be used.

Description Pseudocode statement

a statement to count FOR Count 1 TO 10

Value Value + NewValue


a statement to total

WHILE Value > 10 DO

a statement to start a
pre-condition loop Value Value + 1

a statement to start a REPEAT


post-condition loop

[4]

© UCLES 2023 0478/22/F/M/23


3

(b) Write an algorithm in pseudocode, using a single loop, to output the average of 50 numbers
that have been stored in the array Number[]

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

3 Describe the purpose of test data. Include an example of a type of test data in your answer.

Description .......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2023 0478/22/F/M/23 [Turn over


4

4 Describe how variables and constants are used in programming.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

5 A food ordering system is an example of a computer system that is made up of sub-systems.

The food ordering system:


• allows the user to enter the details of the food they want to order and to pay for the order
• displays food available as pictures or as a list.

Complete the structure diagram for the given parts of the food ordering system.

Food ordering system

[4]

© UCLES 2023 0478/22/F/M/23


5

6 The energy efficiency of an electrical appliance is the percentage of useful energy out compared with
the total energy in.

An algorithm has been written in pseudocode to calculate the energy efficiency of an appliance.
Values for total energy in and useful energy out are input. The efficiency is calculated and output
as a percentage.
The entry of the number –1 for either value stops the algorithm.

01 REPEAT
02 OUTPUT "Enter total energy in "
03 INPUT TotalEnergyIn
04 OUTPUT "Enter useful energy out "
05 OUTPUT UsefulEnergyOut
06 IF TotalEnergyIn <> -1 AND UsefulEnergy <> -1
07 THEN
08 Efficiency (UsefulEnergyOut / TotalEnergyIn) * 100
09 OUTPUT "Efficiency is ", Efficiency, "%"
10 ENDIF
11 UNTIL TotalEnergyIn <> -1 OR UsefulEnergyOut <> -1

(a) Identify the three errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[3]

(b) Write pseudocode to check for an efficiency of 92% or over for this appliance and to output
“A-rated” if the efficiency is 92% or over.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/F/M/23 [Turn over


6

7 Consider this logic expression.

X = (A OR NOT B) AND (B AND NOT C)

(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two
inputs. Do not simplify this logic expression.

B X

[5]

(b) Complete the truth table from the given logic expression.

Working space
A B C X

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

© UCLES 2023 0478/22/F/M/23


7

BLANK PAGE

© UCLES 2023 0478/22/F/M/23 [Turn over


8

8 This flowchart represents an algorithm to find the average value of a number of sales.

START

NumberSales 0
Total 0

INPUT
SaleValue

IS Yes
SaleValue Average Total / NumberSales
= 0?

No OUTPUT
"Average sale
NumberSales NumberSales + 1 value ", Average

Total Total + SaleValue STOP

(a) Complete the trace table using this data:


5.50, 3.40, 6.25, 3.85, –11.00, 0

NumberSales Total SaleValue Average OUTPUT

[4]

© UCLES 2023 0478/22/F/M/23


9

(b) Identify the error in the algorithm and describe how to correct it.

Error ..........................................................................................................................................

...................................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/22/F/M/23 [Turn over


10

9 A shop that sells books has set up a new database table called BookList to store book details.
Part of this table is given.

CatNo Title Fiction Author PaperBack Price StockLevel


BK01 The Princes’ Story Yes B Penn Yes 4.50 500
BK02 The Princesses’ Story Yes B Penn Yes 4.50 350
BK03 Computer Science No Way Yu Yes 19.99 20
BK04 The Modern World No P Patel No 25.00 5
BK05 The Ancient World Yes P Patel No 25.00 5
BK06 Computer Science No R Dale Yes 27.35 8
BK07 The Princes’ Story Yes B Penn No 12.50 3
BK08 The Princesses’ Story Yes B Penn No 12.50 0
BK12 Famous Five Yes E Bly Yes 2.75 45
BK15 Secret Seven Yes E Bly Yes 2.75 25
BK16 The Last Knight Yes P Mann Yes 5.99 7
BK17 The Dark Tower Yes P Mann Yes 5.99 5
BK19 The Final Chase Yes P Mann Yes 5.99 5
BK21 Maths Today Part 1 No B Ward Yes 6.75 25
BK22 Maths Today Part 2 No B Ward Yes 6.75 15
BK23 Maths Today Part 3 No B Ward Yes 6.75 10
BK26 Maths Today Workbook No B Ward Yes 6.75 30
BK27 Knitting for Beginners No A Smith Yes 6.99 3
BK30 Woodwork for Beginners No A Smith Yes 6.99 4
BK31 Networking for Beginners No A Smith Yes 6.99 0

(a) State the number of records in this part of the database table.

............................................................................................................................................. [1]

(b) (i) Give the name of the field that would be used for the primary key.

..................................................................................................................................... [1]

(ii) State the reason for choosing this field for the primary key.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2023 0478/22/F/M/23


11

(c) Complete the table to identify the most appropriate data type for each field based on the data
shown in the table BookList

Field Data type

CatNo

Title

Fiction

Price

[2]

(d) Write the output from this structured query language (SQL) statement.

SELECT CatNo, Title, Author

FROM BookList

WHERE StockLevel = 0;

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(e) Complete this SQL statement to display all the titles by the author B Penn.

SELECT .....................................................................................................................................

FROM .........................................................................................................................................

WHERE .....................................................................................................................................;
[2]

© UCLES 2023 0478/22/F/M/23 [Turn over


12

10 The variables X, Y and Z are used in a program: X stores a whole number, Y stores a decimal
number and Z stores a flag that can be set to TRUE or FALSE

(a) Write pseudocode statements to declare the variables X, Y and Z

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) The function Same(A,B) returns TRUE if the value of A is the same as the value of B when B
is rounded to the nearest whole number and FALSE otherwise.

Write pseudocode statements to:


• define the function
• call the function with X and Y and store the return value in Z

Function definition ....................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Function call .............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[6]

(c) State the difference between defining and calling a function.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2023 0478/22/F/M/23


13

BLANK PAGE

© UCLES 2023 0478/22/F/M/23 [Turn over


14

11 The one-dimensional (1D) array TeamName[] contains the names of teams in a sports league.
The two-dimensional (2D) array TeamPoints[] contains the points awarded for each match.
The position of each team’s data in the two arrays is the same. For example, the team stored at
index 10 in TeamName[] and TeamPoints[] is the same.

The variable LeagueSize contains the number of teams in the league. The variable MatchNo
contains the number of matches played. All teams have played the same number of matches.

The arrays and variables have already been set up and the data stored.

Each match can be played at home or away. Points are recorded for the match results of each
team with the following values:
• 3 – away win
• 2 – home win
• 1 – drawn match
• 0 – lost match.

Write a program that meets the following requirements:


• calculates the total points for all matches played for each team
• counts the total number of away wins, home wins, drawn matches and lost matches for each
team
• outputs for each team:
– name
– total points
– total number of away wins, home wins, drawn matches and lost matches
• finds and outputs the name of the team with the highest total points
• finds and outputs the name of the team with the lowest total points.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.

All inputs and outputs must contain suitable messages.

You do not need to initialise the data in the arrays TeamName[] and TeamPoints[] or the
variables LeagueSize and MatchNo

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

© UCLES 2023 0478/22/F/M/23


15

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/F/M/23 [Turn over
16

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/22/F/M/23


Cambridge IGCSE™
* 4 8 1 6 0 2 0 7 0 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Algorithms, Programming and Logic May/June 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (CJ/CT) 313987/4
© UCLES 2023 [Turn over
2

1 (a) Four descriptions of stages in the program development life cycle are shown.

Draw one line to link each description to its most appropriate program development life cycle
stage.

Not all program development life cycle stages will be used.

Program development life cycle description Program development life cycle stage

develop an algorithm to solve the problem analysis


by using structure diagrams, flowcharts or
pseudocode

coding

detect and fix the errors in the program


design

identify the problem and its requirements


evaluation

write and implement the instructions to


solve the problem testing
[4]
(b) Identify three of the component parts after a problem has been decomposed.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................
[3]

2 Tick (ü) one box to show the name of the data structure used to store a collection of data of the
same data type.

A Array

B Constant

C Function

D Variable
[1]
© UCLES 2023 0478/21/M/J/23
3

3 (a) Describe what is meant by data validation.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) A validation check is used to make sure that any value that is input is an integer between 30
and 200 inclusive.

Give one example of each type of test data to check that the validation check is working as
intended. Each example of test data must be different.

Give a reason for each of your choices of test data.

Normal test data .......................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Abnormal test data ...................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Extreme test data .....................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[6]

4 Explain the purpose of the library routines DIV and ROUND

DIV ...................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

ROUND ..............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]
© UCLES 2023 0478/21/M/J/23 [Turn over
4

5 An algorithm has been written in pseudocode to allow some numbers to be input. All the positive
numbers that are input are totalled and this total is output at the end.
An input of 0 stops the algorithm.

01 Exit 1←
02 WHILE Exit <> 0 DO
03 INPUT Number
04 IF Number < 0
05 THEN
06 Total ←
Total + Number
07 ELSE
08 IF Number = 0
09 THEN
10 Exit 1 ←
11 ENDIF
12 ENDIF
13 ENDIF
14 OUTPUT "The total value of your numbers is ", Number

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023 0478/21/M/J/23


5

(b) Describe how you could change the corrected algorithm to record and output how many
positive numbers have been included in the final total.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

6 State two features that should be included to create a maintainable program.

Give a reason why each feature should be used.

1 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


6

7 The flowchart represents an algorithm.

START

Pointer 1

INPUT
Letter

IS No
Word[Pointer, 1] Pointer Pointer + 1
= Letter ?

Yes

OUTPUT "Letter ", Letter,


" is represented by ",
Word[Pointer, 2]

OUTPUT "Another Letter?


(Y or N)"

INPUT Choice

Yes IS No
Choice = STOP
'Y' ?

© UCLES 2023 0478/21/M/J/23


7

The table represents the two-dimensional (2D) array Word[] which stores the first half of the
phonetic alphabet used for radio transmission. For example, Word[10,1] is ‘J’.

Index 1 2
1 A Alpha
2 B Bravo
3 C Charlie
4 D Delta
5 E Echo
6 F Foxtrot
7 G Golf
8 H Hotel
9 I India
10 J Juliet
11 K Kilo
12 L Lima
13 M Mike

(a) Complete the trace table for the algorithm by using the input data: F, Y, D, N

Pointer Letter Choice OUTPUT

[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


8

(b) Identify the type of algorithm used.

...................................................................................................................................................

............................................................................................................................................. [1]

(c) Describe one problem that could occur with this algorithm if an invalid character was input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/M/J/23


9

BLANK PAGE

© UCLES 2023 0478/21/M/J/23 [Turn over


10

8 The function LENGTH(Phrase)calculates the length of a string Phrase

(a) Write the pseudocode statements to:


• store the string "The beginning is the most important part" in Phrase
• calculate and output the length of the string
• output the string in upper case.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) Write the output your pseudocode should produce.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/M/J/23


11

9 Consider this logic expression.

Z = (NOT A OR B) AND (B XOR C)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

B Z

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


12

10 A database table called TVRange shows the main features and prices of a range of televisions.

TVCode ScreenSize Satellite SmartTV SoundBar Price$


TV90SaSmSd 90 YES YES YES 9750.00
TV75SaSmSd 75 YES YES YES 8500.00
TV75SaSd 75 YES NO YES 8000.00
TV65SaSmSd 65 YES YES YES 6000.00
TV65SmSd 65 NO YES YES 5000.00
TV65SaSd 65 YES NO YES 5000.00
TV55SaSmSd 55 YES YES YES 4000.00
TV55SaSd 55 YES NO YES 3500.00
TV55SmSd 55 NO YES YES 3500.00
TV50SaSmSd 50 YES YES YES 2500.00
TV50Sa 50 YES NO NO 1750.00
TV50Sm 50 NO YES NO 1750.00
TV40Sa 40 YES NO NO 1200.00
TV40 40 NO NO NO 950.00
TV32 32 NO NO NO 650.00

(a) Give the name of the field that is most suitable to be the primary key.

State the reason for this choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/21/M/J/23


13

(b) The database uses the data types:


• text
• character
• Boolean
• integer
• real
• date/time.

Complete the table to show the most appropriate data type for each field.
Each data type must be different.

Field Data type


TVCode
ScreenSize
SmartTV
Price$
[2]

(c) Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table.

SELECT TVCode, ......................................................., .......................................................

....................................................... TVRange

WHERE SmartTV = .......................................................;


[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


14

11 A one-dimensional (1D) array Days[] contains the names of the days of the week. A
two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once
an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.

The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]

The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0 °C to +50.0 °C inclusive.

Write a program that meets the following requirements:


• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9 / 5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.

All inputs and outputs must contain suitable messages.

All data output must be rounded to one decimal place.

You will need to initialise and populate the array Days[] at the start of the program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23
15

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23 [Turn over
16

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/21/M/J/23


Cambridge IGCSE™
* 4 7 9 7 8 7 7 8 2 9 *

COMPUTER SCIENCE 0478/22


Paper 2 Algorithms, Programming and Logic May/June 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (RW/SW) 313988/5
© UCLES 2023 [Turn over
2

1 Tick (✓) one box to identify the first stage of the program development life cycle.

A Analysis

B Coding

C Design

D Testing
[1]

2 Four logic gates and five standard symbols for logic gates are shown.

Draw one line to link each logic gate to its standard symbol. Not all standard symbols will be used.

Logic gate Standard symbol

AND

OR

NAND

NOT

[4]

3 Identify three different ways that the design of a solution to a problem can be presented.

1 .......................................................................................................................................................

..........................................................................................................................................................

2 .......................................................................................................................................................

..........................................................................................................................................................

3 .......................................................................................................................................................

..........................................................................................................................................................
[3]

© UCLES 2023 0478/22/M/J/23


3

4 A program needs to make sure the value input for a measurement meets the following rules:
• the value is a positive number
• a value is always input
• the value is less than 1000.

(a) Describe the validation checks that the programmer would need to use.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

(b) The program needs editing to include a double entry check for the value input.

(i) State why this check needs to be included.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) The input value needs to be stored in the variable Measurement


Write pseudocode to perform the double entry check until a successful input is made.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2023 0478/22/M/J/23 [Turn over


4

5 Circle five file-handling operations.

calculate close count create input open

output print read sort search

test total write


[5]

6 State three different features of a high-level programming language that a programmer could use
to make sure that their program will be easier to understand by another programmer.
Give an example for each feature.

Feature 1 ..........................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

Feature 2 ..........................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................

Feature 3 ..........................................................................................................................................

..........................................................................................................................................................

Example ...........................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2023 0478/22/M/J/23


5

BLANK PAGE

© UCLES 2023 0478/22/M/J/23 [Turn over


6

7 An algorithm has been written in pseudocode to calculate a check digit for a four-digit number.
The algorithm then outputs the five-digit number including the check digit.
The algorithm stops when –1 is input as the fourth digit.

01 Flag FALSE
02 REPEAT
03 Total 0
04 FOR Counter 1 TO 4
05 OUTPUT "Enter a digit ", Counter
06 INPUT Number[Counter]
07 Total Total + Number * Counter
08 IF Number[Counter] = 0
09 THEN
10 Flag TRUE
11 ENDIF
12 NEXT Counter
13 IF NOT Flag
14 THEN
15 Number[5] MOD(Total, 10)
16 FOR Counter 0 TO 5
17 OUTPUT Number[Counter]
18 NEXT
19 ENDIF
20 UNTIL Flag

(a) Give the line number(s) for the statements showing:

Totalling ....................................................................................................................................

Count-controlled loop ...............................................................................................................

Post-condition loop ...................................................................................................................


[3]

(b) Identify the three errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/22/M/J/23


7

(c) The algorithm does not check that each input is a single digit.
Identify the place in the algorithm where this check should occur.
Write pseudocode for this check.
Your pseudocode must make sure that the input is a single digit and checks for –1

Place in algorithm .....................................................................................................................

Pseudocode ..............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

8 Consider this logic expression.

X = (A OR B) AND (NOT B AND C)

Complete the truth table for this logic expression.

Working space
A B C X

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

© UCLES 2023 0478/22/M/J/23 [Turn over


8

9 This flowchart represents an algorithm.

START

F 0
C 1

IS X[C] < No
T X[C]
X[C + 1]?

Yes
X[C] X[C + 1]

X[C + 1] T

F 1

C C + 1

No
IS C = 5?

Yes

No
IS F = 0?

Yes

STOP

© UCLES 2023 0478/22/M/J/23


9

(a) The array X[1:5] used in the flowchart contains this data:

X[1] X[2] X[3] X[4] X[5]

10 1 5 7 11

Complete the trace table by using the data given in the array.

F C X[1] X[2] X[3] X[4] X[5] T

10 1 5 7 11

[5]

(b) Describe what the algorithm represented by the flowchart is doing.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/M/J/23 [Turn over


10

10 A music streaming service has a new database table named Songs to store details of songs
available for streaming. The table contains the fields:
• SongNumber – the catalogue number, for example AG123
• Title – the title of the song
• Author – the name of the song writer(s)
• Singer – the name of the singer(s)
• Genre – the type of music, for example rock
• Minutes – the length of the song in minutes, for example 3.75
• Recorded – the date the song was recorded.

(a) Identify the field that will be the most appropriate primary key for this table.

............................................................................................................................................. [1]

(b) Complete the table to identify the most appropriate data type for the fields in Songs

Field Data type

SongNumber

Title

Recorded

Minutes

[2]

(c) Explain the purpose of the structured query language (SQL) statements.

SUM (Minutes) FROM Songs WHERE Genre = "rock";

COUNT (Title) FROM Songs WHERE Genre = "rock";

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2023 0478/22/M/J/23


11

11 The variables P and Q are used to store data in a program. P stores a string. Q stores a character.

(a) Write pseudocode statements to declare the variables P and Q, store "The world" in P and
store 'W' in Q

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Write a pseudocode algorithm to:


• convert P to upper case
• find the position of Q in the string P (the first character in this string is in position 1)
• store the position of Q in the variable Position

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(c) Give the value of Position after the algorithm has been executed with the data in
question 11(a).

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2023 0478/22/M/J/23 [Turn over


12

12 A two-dimensional (2D) array Account[] contains account holders’ names and passwords for a
banking program.

A 2D array AccDetails[] has three columns containing the following details:


• column one stores the balance – the amount of money in the account, for example 250.00
• column two stores the overdraft limit – the maximum total amount an account holder can
borrow from the bank after the account balance reaches 0.00, for example 100.00
• column three stores the withdrawal limit – the amount of money that can be withdrawn at one
time, for example 200.00

The amount of money in a bank account can be negative (overdrawn) but not by more than the
overdraft limit.
For example, an account with an overdraft limit of 100.00 must have a balance that is greater than
or equal to –100.00

Suitable error messages must be displayed if a withdrawal cannot take place, for example if the
overdraft limit or the size of withdrawal is exceeded.

The bank account ID gives the index of each account holder’s data held in the two arrays.
For example, account ID 20’s details would be held in:
Account[20,1] and Account[20,2]
AccDetails[20,1] AccDetails[20,2] and AccDetails[20,3]

The variable Size contains the number of accounts.

The arrays and variable Size have already been set up and the data stored.

Write a program that meets the following requirements:


• checks the account ID exists and the name and password entered by the account holder
match the name and password stored in Account[] before any action can take place
• displays a menu showing the four actions available for the account holder to choose from:
1. display balance
2. withdraw money
3. deposit money
4. exit
• allows an action to be chosen and completed. Each action is completed by a procedure
with a parameter of the account ID.

You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.

You only need to declare any local arrays and local variables that you use.

You do not need to declare and initialise the data in the global arrays Account[] and
AccDetails[] and the variable Size

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/M/J/23
13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/M/J/23 [Turn over
14

..........................................................................................................................................................

.........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]
© UCLES 2023 0478/22/M/J/23
15

BLANK PAGE

© UCLES 2023 0478/22/M/J/23


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/22/M/J/23


Cambridge IGCSE™
* 5 0 9 3 7 8 1 8 6 5 *

COMPUTER SCIENCE 0478/23


Paper 2 Algorithms, Programming and Logic May/June 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (CJ/CGW) 313989/4
© UCLES 2023 [Turn over
2

1 Tick (3) one box to complete the sentence.

A constant

A stores a value that can change at any time during the execution of a program.

B stores a value that cannot change during the execution of a program.

C stores values of multiple data types.

D stores values that must be of the same data type.


[1]

2 Explain the purpose of the library routines MOD and RANDOM

MOD ...................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

RANDOM ............................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

3 Describe what happens when a function is called during the execution of a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2023 0478/23/M/J/23


3

4 (a) Explain why verification checks are used when data is input.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Give two types of verification check and state how each one can be used.

Verification check 1 ...................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................

Verification check 2 ...................................................................................................................

Use ...........................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023 0478/23/M/J/23 [Turn over


4

5 (a) Four descriptions of validation checks are shown.

Draw one line to link each description to the most appropriate check.

Not all checks will be used.

Description Check

to check that the data entered is an integer check digit

format check
to check that some data has been entered

length check
to check that the data entered has an appropriate
number of characters
presence check

to check that an identification number contains


no errors type check
[4]

(b) Write an algorithm in pseudocode to make sure that an input for the variable Length is
between 15 and 35 inclusive. The code must iterate until a valid input has been made and the
code must include appropriate messages.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

6 An algorithm has been written in pseudocode to allow 100 positive numbers to be input. The total
and the average of the numbers are output.
01 Counter 100
02 Total 0
03 WHILE Counter > 100 DO
04 INPUT Number
05 IF Number > 0
06 THEN
07 Total Total + Counter
08 Counter Counter + 1
09 ENDCASE
10 ENDWHILE
11 OUTPUT "The total value of your numbers is ", Total
12 OUTPUT "The average value of your numbers is ", Total / 100

© UCLES 2023 0478/23/M/J/23


5

(a) Identify the four errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction ..................................................................................................................................

...................................................................................................................................................
[4]

(b) Describe the changes you should make to the corrected algorithm so that a count-controlled
loop is used to allow 100 positive numbers to be input.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2023 0478/23/M/J/23 [Turn over


6

7 The flowchart represents an algorithm.


An input of –1 will terminate the algorithm.

START

Total 0

INPUT
Value

IS Yes
Value =
–1 ?

No OUTPUT
OUTPUT Total
"Rejected" Five1 Value DIV 5

STOP
Five2 Value / 5

No IS
Five1 =
Five2 ?

Yes

Ten1 Value DIV 10

Ten2 Value / 10

No IS
Ten1 =
Ten2 ?

Yes
Total Total + Value
© UCLES 2023 0478/23/M/J/23
7

(a) Complete the trace table for the input data:

5, 50, 52, 555, 57, 500, –1, 5500, 55

Total Value Five1 Five2 Ten1 Ten2 OUTPUT

[6]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/23/M/J/23 [Turn over


8

8 Consider the logic expression:

Z is 1 if (A = 1 AND C = NOT 1) AND (B = 1 NOR C = 1)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

B Z

[4]
(b) Complete the truth table from the given logic expression.

Working space
A B C Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

© UCLES 2023 0478/23/M/J/23


9

9 The variable Saying is used to store string data in a program.

(a) Write the pseudocode statement to declare the variable Saying

...................................................................................................................................................

............................................................................................................................................. [1]

(b) Write the pseudocode statements to:


• allow a string to be input to the variable Saying
• store the content of the variable Saying in a text file named "Quotations.txt"
• make sure the text file is closed at the end of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

© UCLES 2023 0478/23/M/J/23 [Turn over


10

10 A database table called Site1 stores details of some holiday homes at a holiday park. The
database shows the type of home, number of guests, whether it is privately owned and the weekly
rate to hire it.

Name Type Private Rate$ NumberGuest


Bay Lodge Lodge NO 1000 10
Bay View Cabin NO 400 4
Blue Skies Cabin NO 350 4
Cliff View Cabin NO 650 6
Coppice Lodge Lodge NO 1200 12
Green Lodge Lodge NO 1000 8
Henry Cabin YES 300 2
Hikers’ Rest Retreat NO 750 6
Poppy Cabin NO 300 2
Summer Joy Retreat YES 750 6
Valley View Cabin NO 600 6
West Lodge Lodge YES 1200 12

(a) State the number of fields and the number of records in this database table.

Fields ........................................................................................................................................

Records ....................................................................................................................................
[2]

(b) Describe the purpose of a primary key.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2023 0478/23/M/J/23


11

(c) The database uses the data types:


• alphanumeric
• character
• Boolean
• integer
• real
• date/time.

Complete the table to show the most appropriate data type for each field.

Field Data type


Type
Private
Rate$
NumberGuest
[2]

(d) Give the output that would be produced by the structured query language (SQL) statement:

SELECT Name, NumberGuest, Rate$


FROM Site1
WHERE NumberGuest >= 10;

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2023 0478/23/M/J/23 [Turn over


12

11 A two-dimensional (2D) array Contacts[] is used to store names and telephone numbers. All
the data is stored as strings. The array must have the capacity to store 100 contacts in the form of:
• column 1 – contact names as: last name, first name
for example: Smith, John
• column 2 – telephone numbers.

The variable CurrentSize shows how many contacts are in the array.

Write a program that meets the following requirements:


• display a menu of choices:
○ enter new contact details
○ display all the contact details
○ delete all the contact details
• validate the menu input
• allow up to a maximum of five new contacts to be added to the array at any one time
• do not allow more than 100 contacts in total
• after new contacts have been added, sort the array by contact name, as long as there are at
least two contacts in the array
• output the whole of the array
• delete the contents of the array.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.

All inputs and outputs must contain suitable messages.

You do not need to initialise the data in the array Contacts[] and the variable CurrentSize

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

© UCLES 2023 0478/23/M/J/23


13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/M/J/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/23/M/J/23


15

BLANK PAGE

© UCLES 2023 0478/23/M/J/23


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/23/M/J/23


Cambridge IGCSE™
* 5 6 2 6 6 1 3 3 2 9 *

COMPUTER SCIENCE 0478/21


Paper 2 Algorithms, Programming and Logic October/November 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (LK/SG) 314037/5
© UCLES 2023 [Turn over
2

1 Tick (3) one box to show which operator means less than or equal to.

A OR

B <

C <=

D >=
[1]

2 Tick (3) one box to show how a value can be passed to a procedure.

A function

B parameter

C return

D subroutine
[1]

3 Four descriptions of data and five data types are shown.

Draw one line to link each description to the most appropriate data type.
Not all data types will be used.

Description Data type

BOOLEAN
a whole number

CHAR
a single letter

INTEGER

a word or phrase
REAL

a number with two decimal places STRING

[4]

© UCLES 2023 0478/21/O/N/23


3

4 Circle the three words representing places where data may be stored.

array constant dimension input

output procedure variable


[3]

5 The first stage of the program development life cycle is analysis. Two of the tasks in analysis are
abstraction and decomposition.

(a) Describe what is meant by abstraction.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Identify three of the component parts when a problem has been decomposed at the analysis
stage.

1 ................................................................................................................................................

2 ................................................................................................................................................

3 ................................................................................................................................................
[3]

(c) Identify and describe one other stage of the program development life cycle.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/O/N/23 [Turn over


4

6 An algorithm has been written in pseudocode.

01 DECLARE A[1:10] : STRING


02 DECLARE T : STRING
03 DECLARE C, L : INTEGER
04 L 10
05 FOR C 1 TO L
06 OUTPUT "Please enter name "
07 INPUT A[C]
08 NEXT C
09 FOR C 1 TO L
10 FOR L 1 TO 9
11 IF A[L] > A[L + 1]
12 THEN
13 T A[L]
14 A[L] A[L + 1]
15 A[L + 1] T
16 ENDIF
17 NEXT L
18 NEXT C
19 FOR C 1 TO L
20 OUTPUT "Name ", C, " is ", A[C]
21 NEXT C

(a) State the purpose of this pseudocode algorithm.

...................................................................................................................................................

............................................................................................................................................. [1]

© UCLES 2023 0478/21/O/N/23


5

(b) State four processes in this algorithm.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................

4 ................................................................................................................................................

...................................................................................................................................................
[4]

(c) Meaningful identifiers have not been used in this algorithm.


Suggest suitable meaningful identifiers for:

The array:

A ................................................................................................................................................

The variables:

T ................................................................................................................................................

C ................................................................................................................................................

L ................................................................................................................................................
[3]

(d) State two other ways the algorithm can be made easier to understand and maintain.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/21/O/N/23 [Turn over


6

7 Consider this logic circuit.

B X

(a) Write a logic expression for this logic circuit. Do not attempt to simplify this logic expression.

X = ............................................................................................................................................

...................................................................................................................................................
[4]

(b) Complete the truth table from the given logic circuit.

Working space
A B C X

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]

© UCLES 2023 0478/21/O/N/23


7

BLANK PAGE

© UCLES 2023 0478/21/O/N/23 [Turn over


8

8 A programmer is designing an algorithm to calculate the cost of a length of rope.


The program requirements are:
• input two values: the length of rope in metres Length and the cost of one metre Cost
• perform a validation check on the length to ensure that the value is between 0.5 and 6.0
inclusive
• calculate the price Price
• output the price rounded to two decimal places.

Use the variable names given.

(a) State the name of the validation check.

............................................................................................................................................. [1]

(b) Complete the flowchart for this algorithm.

START

STOP

[6]
© UCLES 2023 0478/21/O/N/23
9

(c) Give two different sets of test data for this algorithm and state the purpose of each set.

Set 1 .........................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Set 2 .........................................................................................................................................

Purpose ....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[4]

(d) Complete the headings for the trace table to show a dry-run for this algorithm.
You do not need to trace the algorithm.

.................................. .................................. .................................. ..................................

[3]

(e) Describe an improvement that should be made to the requirements for this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/21/O/N/23 [Turn over


10

9 A model shop wants to set up a database to help with stock control of the model figures available
for sale. The shop wants to store this information about the model figures:
Field 1 – catalogue number, for example MD1234
Field 2 – description, for example ‘small white dog’
Field 3 – number in stock, for example 5
Field 4 – the price of each model, for example 7.40
Field 5 – if the model has already been painted, yes or no.

(a) The shop needs five fields for each record.


Give a suitable name and data type for each field.

Field 1 name .............................................................................................................................

Data type ..................................................................................................................................

Field 2 name ..............................................................................................................................

Data type ..................................................................................................................................

Field 3 name .............................................................................................................................

Data type ..................................................................................................................................

Field 4 name .............................................................................................................................

Data type ..................................................................................................................................

Field 5 name .............................................................................................................................

Data type ..................................................................................................................................


[5]

(b) (i) Give the name of the field that should be used for the primary key.

..................................................................................................................................... [1]

(ii) State why this field is used as the primary key.

..................................................................................................................................... [1]

(c) Structured query language (SQL) is used to query data stored in this database.
State what these SQL commands are used for.

SELECT .....................................................................................................................................

...................................................................................................................................................

FROM .........................................................................................................................................

...................................................................................................................................................

WHERE .......................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/21/O/N/23


11

BLANK PAGE

© UCLES 2023 0478/21/O/N/23 [Turn over


12

10 Drama students put on a performance of a play for one evening. Seats in a small theatre can be
booked for this performance.

The theatre has 10 rows of 20 seats. The status of the seat bookings for the evening is held in the
two-dimensional (2D) Boolean array Evening[]

Each element contains FALSE if the seat is available and TRUE if the seat is booked.

Up to and including four seats can be booked at one time. Seats are allocated in order from those
available. A row or seat number cannot be requested.

The array Evening[] has already been set up and some data stored.

Write a program that meets the following requirements:


• counts and outputs the number of seats already booked for the evening
• allows the user to input the number of seats required
• validates the input
• checks if enough seats are available:
– if they are available
○ changes the status of the seats
○ outputs the row number and seat number for each seat booked
– if they are not available:
○ outputs a message giving the number of seats left or ‘House full’ if the theatre is fully
booked.

You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
You do not need to initialise the data in the array Evening[]
All inputs and outputs must contain suitable messages.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

© UCLES 2023 0478/21/O/N/23


13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/21/O/N/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/21/O/N/23


15

BLANK PAGE

© UCLES 2023 0478/21/O/N/23


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/21/O/N/23


Cambridge IGCSE™
* 3 4 3 5 3 7 0 0 4 3 *

COMPUTER SCIENCE 0478/22


Paper 2 Algorithms, Programming and Logic October/November 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (RW/SG) 314039/4
© UCLES 2023 [Turn over
2

1 Tick (✓) one box to complete the sentence.

Verification is used to make sure that a value entered

A has not changed during input.

B is an integer.

C is correct.

D is not a string.
[1]

2 A type of validation check is a length check. Another type of validation check is used to make sure
that any date entered is in the dd/mm/yyyy style:
dd means day, mm means month and yyyy means year.

(a) State the type of validation check used.

............................................................................................................................................. [1]

(b) Give one example of normal test data and one example of abnormal test data you should
use to make sure the check in part (a) is working properly.

State a reason for each of your choices of test data.

Normal ......................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................

Abnormal ..................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[4]

(c) Describe how a length check could be used with the date entered.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/O/N/23


3

3 Four pseudocode statements and five pseudocode uses are shown.

(a) Draw one line to link each pseudocode statement to the most appropriate pseudocode use.

Not all pseudocode uses will be required.

Pseudocode statement Pseudocode use

CALL Colour(NewColour) counting

finding an average
Value (A1 + A2 + A3) / 3

totalling

Loop1 Loop1 + 1
using a conditional statement

IF Count > 7 THEN X1 0 using a procedure


[4]

(b) A one‑dimensional (1D) array called Temperatures[] has 25 elements beginning at


index 1. It holds values that range between –20 and 100 inclusive.

Write a pseudocode algorithm using a single loop to find the lowest value in this array and
output the result only once.

You do not need to declare or populate this array.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2023 0478/22/O/N/23 [Turn over
4

4 An algorithm has been written in pseudocode to allow the names of 50 cities and their countries to
be entered and stored in a two‑dimensional (2D) array. The contents of the array are then output.

01 DECLARE City ARRAY[1:50, 1:2] OF BOOLEAN


02 DECLARE Count : INTEGER
03 DECLARE Out : INTEGER
04 Count 1
05 IF
06 OUTPUT "Enter the name of the city"
07 INPUT City[Count, 2]
08 OUTPUT "Enter the name of the country"
09 INPUT City[Count, 2]
10 Count Count + 1
11 UNTIL Count = 50
12 FOR Out 1 TO 1
13 OUTPUT "The city ", City[Out, 1], " is in ", City[Out, 2]
14 NEXT Out

(a) Identify the four errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2023 0478/22/O/N/23


5

(b) Describe the changes you should make to the corrected algorithm to allow the name of a
country to be input and to display only the stored cities from that country.

You do not need to rewrite the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [5]

5 Explain how variables and constants should be used when creating and running a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [3]

© UCLES 2023 0478/22/O/N/23 [Turn over


6

6 The flowchart represents an algorithm that performs a process on groups of values that are input.
The algorithm will fail if the first value of any group is 0.

An input of –1 will terminate the algorithm.

START

Total 0
OUTPUT
"Average is ",
Average
Count 0

INPUT OUTPUT
Value "Total is ",
Total

IS Yes
Value = Average Total / Count
0 ?

No

IS Yes
Value = STOP
–1 ?

No

Total Total + Value

Count Count + 1

© UCLES 2023 0478/22/O/N/23


7

(a) Complete the trace table for the input data:

25, 35, 3, 0, 57, 20, 25, 18, 0, –1, 307, 40, 0

Value Average Total Count OUTPUT

[5]

(b) Describe the purpose of the algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2023 0478/22/O/N/23 [Turn over


8

7 The string operation SUBSTRING(Quote, Start, Number) returns a string from Quote
beginning at position Start that is Number characters long. The first character in Quote is in
position 1.

Write pseudocode statements to:


• store the string "Learning Never Exhausts The Mind" in Quote
• extract and display the words "The Mind" from the string
• output the original string in lower case.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [5]

8 Explain why a programmer would use procedures and parameters when writing a program.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................... [4]

© UCLES 2023 0478/22/O/N/23


9

9 Consider the logic expression:

Z = (A NAND B) OR NOT (B XOR C)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

B Z

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1
[4]

© UCLES 2023 0478/22/O/N/23 [Turn over


10

10 A database table called Horses stores details about the horses kept at a horse sanctuary.

Code Breed BreedOrigin Gender Age Arrived


H002 Arabian Saudi Arabia M 5 28/09/2022
H004 Percheron France M 5 30/10/2022
H010 Friesian Netherlands M 6 15/11/2022
H011 Fjord Norway F 4 17/11/2022
H012 Clydesdale Scotland M 10 18/11/2022
H015 Arabian Saudi Arabia F 5 15/12/2022
H016 Arabian Saudi Arabia F 5 15/12/2022
H017 Clydesdale Scotland F 4 16/01/2023
H019 Percheron France M 3 16/01/2023
H025 Percheron France M 7 16/01/2023
H026 Clydesdale Scotland F 9 20/01/2023
H030 Clydesdale Scotland M 12 20/01/2023
H032 Fjord Norway M 3 24/03/2023
H033 Arabian Saudi Arabia F 15 27/04/2023
H034 Clydesdale Scotland F 4 14/06/2023
H035 Fjord Norway M 7 15/06/2023
H036 Friesian Netherlands F 15 20/07/2023
H037 Friesian Netherlands M 12 20/07/2023

(a) State the number of records in this database table.

............................................................................................................................................. [1]

(b) Give the name of the field that is most suitable to be the primary key.

State the reason for this choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/22/O/N/23


11

(c) The database only allows the data types:


• Boolean
• character
• date/time
• integer
• real
• text.

Complete the table to show the most appropriate data type for each field.
Each data type must be different.

Field Data type


Breed

Gender

Age

Arrived
[2]

(d) Complete the structured query language (SQL) to return the code and breed of all the horses
whose breed originated in Scotland.

......................................... Code, Breed,

FROM .........................................

WHERE ......................................... = "Scotland";


[3]

© UCLES 2023 0478/22/O/N/23 [Turn over


12

11 A wood flooring company stores the names of up to 100 customers in a one‑dimensional (1D) array
Customers[]. A two‑dimensional (2D) array Quotations[] stores details of each customer’s
quotation:
• length of room (one decimal place)
• width of room (one decimal place)
• area of wood required (rounded up to next whole number)
• choice of wood index (whole number)
• price of wood required in dollars (two decimal places).

The floor measurements (room length and room width) are taken in metres. All floors are rectangles
and room measurements must be between 1.5 and 10.0 inclusive.

The index of any customer’s data is the same in both arrays. For example, a customer named in
index 4 of Customers[] corresponds to the data in index 4 of Quotations[]

The wood choices available are:

Index Wood type Price per square metre ($)


1 Laminate 29.99
2 Pine 39.99
3 Oak 54.99

The data are stored in two 1D arrays named WoodType[] and Price[]. The index of the wood
type and price in their arrays share the same index number.

Write a program that meets the following requirements:


• input a new customer’s name, room length and room width
• check that each measurement is valid
• output an error message and require the measurement to be re‑entered until it is valid
• calculate the area of the room by multiplying together the length of the room and the width of
the room
• input the choice of wood and find its price per square metre
• calculate the price of the wood needed
• store all data in the relevant array
• output the customer’s quotation to include: the name of the customer, the choice of wood and
the calculated price of the wood required
• continue to accept the next customer.

You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; you may assume that this has already been
done.

You will need to initialise WoodType[] and Price[]

All inputs and outputs must contain suitable messages.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/O/N/23
13

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/22/O/N/23 [Turn over
14

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

© UCLES 2023 0478/22/O/N/23


15

BLANK PAGE

© UCLES 2023 0478/22/O/N/23


16

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/22/O/N/23


Cambridge IGCSE™
* 2 5 0 4 8 4 8 1 1 1 *

COMPUTER SCIENCE 0478/23


Paper 2 Algorithms, Programming and Logic October/November 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

DC (CJ/CT) 313523/5
© UCLES 2023 [Turn over
2

1 Tick (3) one box to show which term is an example of a verification check.

A Double entry check

B Format check

C Length check

D Presence check
[1]

2 Tick (3) one box to show which library routine returns the remainder of a division.

A DIV

B MOD

C RANDOM

D ROUND
[1]

© UCLES 2023 0478/23/O/N/23


3

3 (a) Four pseudocode descriptions and five pseudocode keywords are shown.

Draw one line to link each pseudocode description to the most appropriate pseudocode
keyword. Not all pseudocode keywords will be used.

Pseudocode description Pseudocode keyword

stores data in a file OUTPUT

WRITE
retrieves data from a file

READ

displays data on a screen


OPEN

enters data from a keyboard INPUT

[4]

(b) Give two reasons for storing data in a file.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/23/O/N/23 [Turn over


4

4 A programmer is writing a data entry program for booking theatre seats.


The programmer needs the program to accept only whole numbers that are greater than or equal
to one and less than or equal to six.

(a) Give the names of two validation checks that are required for this program.

1 ................................................................................................................................................

2 ................................................................................................................................................
[2]

(b) Complete this pseudocode to perform your two validation checks, using your answers given
in (a):

OUTPUT "Please enter the number of seats you want to book "

INPUT Seats

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

(c) Give one item of test data to use when testing this program.
State the reason for your choice of test data.

Test data ...................................................................................................................................

Reason for choice .....................................................................................................................

...................................................................................................................................................
[2]

© UCLES 2023 0478/23/O/N/23


5

BLANK PAGE

© UCLES 2023 0478/23/O/N/23 [Turn over


6

5 An algorithm has been written in pseudocode to check if a new password is in a list of previously
used passwords OldList[]
If the password is not found, the new password will be stored at the end of the list to replace
"XXXX" already stored there.

01 OUTPUT "Enter your new password "


02 INPUT NewPassword
03 Posn 1
04 Found FALSE
05 REPEAT
06 IF Password = OldList[Posn]
07 THEN
08 Found TRUE
09 ELSE Posn Posn + 1
10 ENDIF
11 UNTIL Found AND OldList[Posn] = "XXXX"
12 IF Found
13 THEN
14 OUTPUT "Password has been used before"
15 ELSE
16 INPUT "New password accepted"
17 OldList[Posn] NewPassword
18 ENDIF

(a) Identify the three errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 .......................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2023 0478/23/O/N/23


7

(b) Complete this flowchart for the corrected algorithm:

START

STOP

[6]

© UCLES 2023 0478/23/O/N/23 [Turn over


8

6 There are three descriptions of logic gates. Each logic gate has two inputs A and B with one
output X.
Identify each logic gate.
Complete a truth table for each logic gate.

(a) The only time the output is 1 is when both inputs are 1.
A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

(b) The output is 1 when both inputs are different.


A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

(c) The only time the output is 1 is when both inputs are 0.
A B X
Logic gate ...............................................
0 0
Complete the truth table for this description.
0 1

1 0

1 1

[2]

© UCLES 2023 0478/23/O/N/23


9

(d) Consider this logic expression:

X = (NOT A OR NOT B) OR NOT C

Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two
inputs. Do not attempt to simplify this logic expression.

B X

[5]

7 A program uses both local variables and global variables.

Describe two differences between local variables and global variables.

Difference 1 ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

Difference 2 ......................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2023 0478/23/O/N/23 [Turn over


10

8 This is an algorithm to find if a batch of parts has been manufactured successfully.

START

Accept 0
Reject 0

INPUT PartOK

No
IS PartOK Reject Reject + 1
= 'Y'?
Yes

Accept Accept + 1

No IS Accept
= 10 ?

Yes

Yes
IS Reject Error Reject/Accept * 100
> 1?

No
OUTPUT
"Too many rejected ",
OUTPUT Error, "% error"
"Success"

STOP

© UCLES 2023 0478/23/O/N/23


11

(a) Complete the trace table using this data:


Y, Y, Y, N, Y, Y, Y, Y, N, Y, Y, Y, Y

Accept Reject PartOK Error OUTPUT

[5]

(b) Describe how the algorithm should be changed to accept ‘Y’ or ‘y’ for a successfully
manufactured part.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

© UCLES 2023 0478/23/O/N/23 [Turn over


12

9 A sanctuary for pheasants has set up a new database table called PheasantList to store details
of the different species of bird at the sanctuary. Part of this table is given, showing: species,
description, number of birds at the sanctuary, if the birds are breeding or not, and number of
young born this year.

Species Description NumberBirds Breeding Young


Edwards blue-black with white tail 5 Yes 0
Japanese green dark green with pale grey tail 2 Yes 2
Reeves golden, white and red scaled plumage 4 Yes 1
Crawfords Kalij glossy blue-black plumage 4 No 0
Crested fireback blue-black with black tail 3 No 0
True silver white laced top half and black lower half 7 Yes 1
Siamese fireback grey plumage with crimson legs and feet 5 No 0
Mikado iridescent plumage with white striped wings 3 Yes 4
Red junglefowl many colours 2 Yes 0
Himalayan monal many colours with metallic green crest 3 Yes 2
White eared white with ear tufts 5 Yes 3
Brown eared brown with ear tufts 9 Yes 1
Ring necked long tail with white ring neck 2 Yes 2
Golden rainbow coloured 3 Yes 4

(a) State the number of records and fields in this part of the database table.

Records .....................................................................................................................................

Fields .........................................................................................................................................
[2]

(b) (i) Give the name of a field that could be used for the primary key.

..................................................................................................................................... [1]

(ii) Explain why the sanctuary might decide not to use the field in (b)(i) as the primary key.

...........................................................................................................................................

..................................................................................................................................... [1]

(iii) A new field SpeciesID is added to the database table.


This field contains a six-character code, for example Ph0001.

Give a reason why this field would be a better primary key.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2023 0478/23/O/N/23


13

(c) Write the output that would be given by this structured query language (SQL) statement:

SELECT Species, Description

FROM PheasantList

WHERE NumberBirds > 6;

...................................................................................................................................................

............................................................................................................................................. [2]

(d) Complete this SQL statement to display all the species of pheasant where the birds are
breeding and there were no young born this year:

SELECT ....................................................................................................................................

FROM ........................................................................................................................................

WHERE ......................................................................................................................................

.............................................................................................................................................. ;
[4]

© UCLES 2023 0478/23/O/N/23 [Turn over


14

10 A weather station takes temperature readings once an hour for a week. These temperatures are
stored in a two-dimensional (2D) array Temperatures[]
Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and
the final temperature at 23:00. There are seven columns, one for each day of the week, starting
with Monday and ending with Sunday.

The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and
average temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store
the maximum, minimum, and average temperatures for the week.

The array has already been set up and the data stored.

Write a program that meets the following requirements:


• finds the maximum and minimum temperatures for each day
• calculates the average temperature for each day
• outputs for each day:
– name of the day, for example Monday
– maximum temperature
– minimum temperature
– average temperature
• finds the maximum and minimum temperatures for the week
• calculates the average temperature for the week
• outputs:
– maximum temperature for the week
– minimum temperature for the week
– average temperature for the week.

All temperatures output must be rounded to two decimal places.

You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.

You do not need to declare any arrays or variables; you may assume that this has already been
done.
You do not need to initialise the data in the array Temperatures[]

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/O/N/23
15

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................
© UCLES 2023 0478/23/O/N/23 [Turn over
16

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

.................................................................................................................................................. [15]

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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/23/O/N/23


Cambridge IGCSE™
*0123456789*

COMPUTER SCIENCE 0478/02


Paper 2 Algorithms, Programming and Logic For examination from 2023

SPECIMEN PAPER 1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● 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 75.
● 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 16 pages. Any blank pages are indicated.

© UCLES 2020 [Turn over


2

1 Four pseudocode descriptions and five pseudocode statements are shown.

(a) Draw a line to link each pseudocode description to the most appropriate pseudocode
statement.

Some pseudocode statements will not be used.

Pseudocode description Pseudocode statement

FOR…TO…NEXT

a loop that will always iterate at


least once

IF…THEN…ELSE…ENDIF

a conditional statement to deal


with many possible outcomes

WHILE…DO…ENDWHILE

a loop that will always iterate a set


number of times

CASE…OF…OTHERWISE…ENDCASE

a conditional statement with


different outcomes for true and false

REPEAT…UNTIL

[4]

(b) Using a single loop, write an algorithm in pseudocode to output 50 names that have been
stored in the array, Name[]

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

................................................................................................................................................[3]

© UCLES 2020 0478/02/SP/23


3

2 Describe the purpose of validation and verification checks during data entry.

Include an example for each.

Validation check.................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

Verification check...............................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................
[4]

© UCLES 2020 0478/02/SP/23 [Turn over


4

3 Tick () one box to show the named section of a program that performs a specific task.

A file

B function

C parameter

D process
[1]

4 A satellite navigation system is an example of a computer system that is made up of sub-systems.

Part of a satellite navigation system:


• allows the user to enter details for a new destination or select a previously saved destination
• displays directions in the form of a visual map or as a list.

Draw a structure diagram for this part of the satellite navigation system.

[4]

© UCLES 2020 0478/02/SP/23


5

5 An algorithm has been written in pseudocode to input some numbers. It only outputs any numbers
that are greater than or equal to 100. The number 999 is not output and stops the algorithm.

INPUT Number
WHILE Numbers <> 999 DO
IF Number > 100
THEN
OUTPUT Number
ENDIF
ENDWHILE
OUTPUT Number

(a) Identify the four errors in the pseudocode and suggest corrections.

Error 1 ........................................................................................................................................

Correction ..................................................................................................................................

....................................................................................................................................................

Error 2 ........................................................................................................................................

Correction ..................................................................................................................................

....................................................................................................................................................

Error 3 ........................................................................................................................................

Correction ..................................................................................................................................

....................................................................................................................................................

Error 4 ........................................................................................................................................

Correction ..................................................................................................................................

....................................................................................................................................................
[4]

(b) Write a pseudocode statement to change the corrected algorithm to output all numbers
between 100 and 200 inclusive.

You do not need to rewrite the whole algorithm

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

............................................................................................................................................... [2]

© UCLES 2020 0478/02/SP/23 [Turn over


6

6 Consider this logic expression.

X = ( A AND B ) OR ( B AND NOT C )

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

B X

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C X

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[4]

© UCLES 2020 0478/02/SP/23


7

BLANK PAGE

© UCLES 2020 0478/02/SP/23 [Turn over


8

7 This flowchart represents an algorithm.

START

Flag  0
Count  1

IS Name[Count] Yes
> Name[Count + 1]? Temp  Name[Count]

No Name[Count]  Name[Count + 1]

Name[Count + 1]  Temp

Flag  1

Count  Count + 1

No IS Count
=4?

Yes

No IS Flag
=0?

Yes

STOP

© UCLES 2020 0478/02/SP/23


9

(a) The array Name[1:4] used in the flowchart contains the following data:

Name[1] Name[2] Name[3] Name[4]


Jamal Amir Eve Tara

Complete the trace table using the data given in the array.

Flag Count Name[1] Name[2] Name[3] Name[4] Temp

Jamal Amir Eve Tara

[5]

(b) Describe what the algorithm represented by the flowchart is doing.

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

............................................................................................................................................... [2]

© UCLES 2020 0478/02/SP/23 [Turn over


10

8 A programmer has written an algorithm to check that prices are less than $10.00

These values are used as test data:

10.00 9.99 ten

State why each value was chosen as test data.

10.00 .................................................................................................................................................

...........................................................................................................................................................

9.99 ...................................................................................................................................................

...........................................................................................................................................................

ten .....................................................................................................................................................

...........................................................................................................................................................
[3]

9 Explain why a program might need to store data in a file.

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...................................................................................................................................................... [3]

10 A function is declared using pseudocode.

FUNCTION ConvertToCm(Inches: REAL) RETURNS REAL


RETURN Inches * 2.4
ENDFUNCTION

Tick () one box which accurately describes the use of the variable Inches

A answer

B call

C parameter

D response
[1]
© UCLES 2020 0478/02/SP/23
11

11 A database table, 2018MOV, is used to keep a record of movie details.

CatNo Title Genre1 Genre2 Blu-ray DVD Streaming


18m01 Power Rangers Adventure Fantasy Yes No Yes
18m02 Baywatch Comedy Drama Yes No Yes
18m03 Table 19 Comedy Drama Yes Yes No
18m04 Wonder Woman Action Fantasy Yes No Yes
18m05 Justice League Action Fantasy Yes Yes Yes
18m06 Twilight Thriller Action Yes Yes No
18m07 Ant Man Action Fantasy No Yes No
18m08 Venice Beach Action History No Yes No
18m12 Fast Five Action Thriller No Yes No
18m15 King Kong Adventure Fantasy No Yes No
18m16 Transformers: The Last Knight Action Sci-Fi Yes Yes Yes
18m17 The Dark Tower Fantasy Sci-Fi Yes Yes No
18m19 Beauty and the Beast Fantasy Romance Yes Yes Yes
18m21 The Mummy Action Fantasy No No Yes
18m22 Star Wars: Episode VIII Sci-Fi Action Yes No Yes
18m23 Guardians of the Galaxy Action Sci-Fi Yes Yes Yes
18m26 Thor Action Sci-Fi No Yes Yes
18m27 Twilight Fantasy Sci-Fi No No Yes
18m30 Beneath Action Fantasy Yes No No
18m31 Despicable Me Animation Action Yes Yes No

(a) State the number of records in the database table.

............................................................................................................................................... [1]

(b) (i) Give the name of the field that would be used for the primary key.

....................................................................................................................................... [1]

(ii) State the reason for choosing this field for the primary key.

............................................................................................................................................

....................................................................................................................................... [1]

© UCLES 2020 0478/02/SP/23 [Turn over


12

(c) Complete the table to identify the most appropriate data type for each field based on the data
shown in the database table, 2018MOV.

Field Data type

CatNo

Title

Genre1

Streaming

[2]

(d) Complete the structured query language (SQL) to return the category number and title for all
Comedy movies.

SELECT CatNo, Title

.................................................. 2018MOV

WHERE Genre1 = ..................................................;


[2]

© UCLES 2020 0478/02/SP/23


13

12 The variables X, Y and Z are used to store data in a program:

• X stores a string
• Y stores a position in the string (e.g. 2)
• Z stores the number of characters in the string.

(a) Write pseudocode statements to declare the variables X, Y and Z.

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

............................................................................................................................................... [3]

(b) The function Length(X) finds the length of a string X.

The function SubString(X,Y,Z) finds a substring of X starting at position Y and Z


characters long. The first character in X is in position 1.

Write pseudocode statements to:


• store the string "Programming is fun" in X
• find the length of the string and output it
• extract the word fun from the string and output it.

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

....................................................................................................................................................

............................................................................................................................................... [6]

© UCLES 2020 0478/02/SP/23 [Turn over


14

13 The 1D array StudentName[] contains the names of students in a class. The 2D array
StudentMark[] contains the mark for each subject, for each student. The position of
each student’s data in the two arrays is the same, for example, the student in position 10 in
StudentName[] and StudentMark[] is the same.

The variable ClassSize contains the number of students in the class. The variable SubjectNo
contains the number of subjects studied. All students study the same number of subjects.

The arrays and variables have already been set up and the data stored.

Students are awarded a grade based on their average mark.

Average mark Grade awarded


greater than or equal to 70 distinction
greater than or equal to 55 and less than 70 merit
greater than or equal to 40 and less than 55 pass
less than 40 fail

Write a program that meets the following requirements:


• calculates the combined total mark for each student for all their subjects
• calculates the average mark for each student for all their subjects, rounded to the nearest
whole number
• outputs for each student:
– name
– combined total mark
– average mark
– grade awarded
• calculates, stores and outputs the number of distinctions, merits, passes and fails for the
whole class.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to initialise the data in the array.

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

© UCLES 2020 0478/02/SP/23


15

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................
© UCLES 2020 0478/02/SP/23 [Turn over
16

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

...........................................................................................................................................................

.................................................................................................................................................... [15]

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.

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/02/SP/23

You might also like