0% found this document useful (0 votes)
21 views96 pages

Complete

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)
21 views96 pages

Complete

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

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
• $QQXDO+ROLGD\QXPEHURIZKROHGD\V·DQQXDOKROLGD\
• 3D\*UDGHWKHHPSOR\HH·VSD\JUDGHZKLFKPXVWEHDVLQJOHOHWWHU$²)

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

&RPSOHWHWKHWUDFHWDEOHIRUWKHLQSXWYDOXHVï

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
)25&RXQWHUĸ72
1XPĸ1XP &RXQWHU
$>&RXQWHU@ĸ1XP
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: 

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


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 GLIIHUHQW YDOXHV RI WHVW GDWD WKDW FRXOG EH XVHG IRU WKH EDE\·V ZHLJKW
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


6

Section B

2 Read this section of program code that should input 10 positive numbers and then out
uttpu
put th
output tthe
he
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 ograms. Parcels w
The flowchart below inputs the weight of a number of parcels in kilograms. eig
ei gh
hin
ng more
weighing mo
more
re
than 25 kilograms are rejected. A value of –1 stops the input.

pa
arc
cel
els
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 ram.
Explain the difference between a variable and a constant in a program.

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

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

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

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

(c) State the data type you would choose for each of the following
g fields.
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: 9 9
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


5

Section B

2 Read this section of program code that should input 30 positive numbers and then out
uttpu
put th
output tthe
he
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 MO
OD gives
edefined function MOD givve
ess the
the
he
value of the remainder, for example, Y @ 10 MOD 3 gives thehe 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 ode are shown belo


Four programming concepts and four examples of programming code lo
ow
w..
below.

ple of programming code.


Draw a line to link each programming concept to the correct example cod
de.
e

Programming
gramming code
Example of programming
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 students
tss. Part
A database, MARKS, was set up to record the test results for a class of students. Pa
Part
r t of
of the
th
he
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 w the student names
name
me
es only
on
nlyy of
of all
al
al
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


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


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: 9 9 9
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


9

Section B

2 7KLVVHFWLRQRISURJUDPFRGHDVNVIRUQXPEHUVWREHHQWHUHG7KHWRWDODQGDYHUDJHRIWKH
QXPEHUVDUHFDOFXODWHG

1 Total = 0
2 Counter = 50
 35,17ƍ:KHQSURPSWHGHQWHUQXPEHUVRQHDWDWLPHƍ
4 REPEAT
 35,17ƍ(QWHUDQXPEHUƍ
 ,13871XPEHU
 7RWDO1XPEHU 7RWDO
 1XPEHU 1XPEHU
9 UNTIL Counter = 50
 $YHUDJH 1XPEHU &RXQWHU
35,17ƍ7KHDYHUDJHRIWKHQXPEHUV\RXHQWHUHGLVƍ$YHUDJH

7KHUHDUHfourHUURUVLQWKLVFRGH

6WDWHWKHOLQHQXPEHUIRUHDFKHUURUDQGZULWHWKHFRUUHFWFRGHIRUWKDWOLQH

(UURU/LQHQXPEHU

&RUUHFWFRGH

(UURU/LQHQXPEHU

&RUUHFWFRGH

(UURU/LQHQXPEHU

&RUUHFWFRGH

(UURU/LQHQXPEHU

&RUUHFWFRGH
>@

‹8&/(6 0- [Turn over


10

3 $ VDWHOOLWH QDYLJDWLRQ V\VWHP ZRUNV XVLQJ GHVWLQDWLRQ GHWDLOV HQWHUHG E\ WKH XVHU HLWKHU D QHZ
GHVWLQDWLRQRUFKRVHQIURPSUHYLRXVO\VDYHGGHVWLQDWLRQV7KHVDWHOOLWHQDYLJDWLRQV\VWHPZLOOWKHQ
RXWSXWGLUHFWLRQVWRWKHGHVWLQDWLRQLQWKHIRUPRIHLWKHUDYLVXDOPDSRUDOLVWRIGLUHFWLRQV

$VDWHOOLWHQDYLJDWLRQV\VWHPLVDQH[DPSOHRIDFRPSXWHUV\VWHPWKDWLVPDGHXSRIVXEV\VWHPV
7KLVVWUXFWXUHGLDJUDPVKRZVVRPHRILWVVXEV\VWHPV

&RPSOHWHWKHGLDJUDPE\ILOOLQJLQWKHHPSW\ER[HV

Satellite navigation system

Input destination

Map List

>@

4 )RUHDFKRIWKHfourVWDWHPHQWVLQWKHWDEOHSODFHDWLFNLQWKHFRUUHFWFROXPQWRVKRZZKHWKHULW
LVDQH[DPSOHRIvalidationRUverification

Statements Validation Verification


7RDXWRPDWLFDOO\FKHFNWKHDFFXUDF\RIDEDUFRGH
7RFKHFNLIWKHGDWDLQSXWLVVHQVLEOH
7RFKHFNLIWKHGDWDLQSXWPDWFKHVWKHGDWDWKDWKDVEHHQ
VXSSOLHG
7RDXWRPDWLFDOO\FKHFNWKDWDOOUHTXLUHGGDWDILHOGVKDYHEHHQ
FRPSOHWHG

>@

© UCLES 2017 0478/21/M/J/17


11

5 (a) 'HVFULEHWKHSXUSRVHRIHDFKVWDWHPHQWLQWKLVDOJRULWKP

FOR I 1 TO 300
,13871DPH>,@
NEXT I









>@

 (b)  ,GHQWLI\DQRWKHUORRSVWUXFWXUHWKDWWKHDOJRULWKPLQpart (a)FRXOGKDYHXVHG



>@

(c) :ULWHDQDOJRULWKPXVLQJSVHXGRFRGHWRLQSXWDQXPEHUEHWZHHQDQGLQFOXVLYH7KH
DOJRULWKPVKRXOGSURPSWIRUWKHLQSXWDQGRXWSXWDQHUURUPHVVDJHLIWKHQXPEHULVRXWVLGH
WKLVUDQJH



















>@

‹8&/(6 0- [Turn over


12

6 7KLVIORZFKDUWLQSXWVDUDQJHRIWHPSHUDWXUHVLQGHJUHHV)DKUHQKHLW

$VHDFKWHPSHUDWXUHLVLQSXWLWLVFRPSDUHGZLWKWKHSUHYLRXVKLJKHVWWHPSHUDWXUH,ILWLVKLJKHU
WKDQWKHFXUUHQWKLJKHVWLWUHSODFHVWKHSUHYLRXVKLJKHVWWHPSHUDWXUHDQGWKHQLWLVFRQYHUWHGWR
GHJUHHV&HOVLXV

)RU HDVH RI FDOFXODWLRQ WKH ILQDO VWHS RI WKH )DKUHQKHLW WR &HOVLXV FRQYHUVLRQ KDV EHHQ
DSSUR[LPDWHGDVGLYLVLRQE\

:KHQ±LVHQWHUHGWKHLQSXWSURFHVVVWRSVDQGWKHKLJKHVWWHPSHUDWXUH LQERWK)DKUHQKHLWDQG
&HOVLXV LVRXWSXW

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

‹8&/(6 0-
13

&RPSOHWHWKHWUDFHWDEOHIRUWKHLQSXWGDWD

±

HighF HighC TempF OUTPUT

>@

‹8&/(6 0- [Turn over


14

7 $WHOHYLVLRQ 79 VWRUHKDVDGDWDEDVHWDEOH79672&.IRULWVQHZUDQJHRIWHOHYLVLRQV7KHWDEOH
VWRUHVWKHVFUHHQVL]HRIHDFK79ZKHWKHULWZLOOVKRZ'ZKHWKHUWKHVFUHHQLVFXUYHGRUIODW
LIWKHLQWHUQHWLVDYDLODEOHRQWKH79LILWKDVDEXLOWLQKDUGGLVNGULYHDQGWKHSULFH3DUWRIWKH
GDWDEDVHWDEOHLVVKRZQEHORZ

TVID ScreenSize 3D CurvedFlat Internet HDD Price


79&9,17  <(6 &9 <(6 <(6 
79&9,17  <(6 &9 <(6 <(6 
79&9,17  <(6 &9 <(6 <(6 
79)7,17  <(6 )7 <(6 <(6 
79&9,17  <(6 &9 <(6 12 
79)7,17  <(6 )7 <(6 12 
79)71,1  <(6 )7 12 12 
79&9,17  <(6 &9 <(6 12 
79)7,17  <(6 )7 <(6 12 
79)71,1  <(6 )7 12 12 
79)7,17  <(6 )7 <(6 12 
79)7,17  12 )7 <(6 12 
79)71,1  12 )7 12 12 
79)71,1  12 )7 12 12 

(a) 6WDWHWKHW\SHRIWKHILHOGTVIDDQGJLYHDUHDVRQIRU\RXUFKRLFH





>@

(b) &RPSOHWHWKHWDEOHZLWKWKHPRVWDSSURSULDWHGDWDW\SHIRUHDFKILHOG

Field name Data type


6FUHHQ6L]H
'
&XUYHG)ODW
,QWHUQHW
+''
3ULFH
>@

‹8&/(6 0-
15

(c) 8VH WKH TXHU\E\H[DPSOH JULG EHORZ WR SURYLGH D OLVW RI DOO RI WKH FXUYHG VFUHHQ79V WKDW
KDYHDEXLOWLQKDUGGLVNGULYH0DNHVXUHWKHOLVWRQO\GLVSOD\VWKH79,'WKHSULFHDQGWKH
VFUHHQVL]HLQDVFHQGLQJRUGHURISULFH

)LHOG
7DEOH
6RUW
6KRZ
&ULWHULD
RU

>@

‹8&/(6 0-
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.

   &RXQWĸ
   6XPĸ
REPEAT
INPUT Number
   6XPĸ6XP1XPEHU
   &RXQWĸ&RXQW
UNTIL Count > 100
PRINT Sum

(a) )LQGWKHHUURULQWKHSVHXGRFRGHDQGVXJJHVWDFRUUHFWLRQ

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.

)LHOGQDPH ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

)LHOGQDPH ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

)LHOGQDPH ..............................................................................................................................

Data type ...................................................................................................................................

Data sample ..............................................................................................................................

)LHOGQDPH ..............................................................................................................................

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.

)LHOG
Table:
Sort:
Show:
Criteria:
or:
[3]

© UCLES 2017 0478/22/M/J/17


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


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
WRDZHEVLWH·VGLVFXVVLRQJURXS

(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
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


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


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


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: 9 9
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


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 [Link] 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


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

You might also like