Computer Science (0478) · Feb/March 2017 · Question paper 22

Cambridge Computer Science (0478) question paper for paper 22, Feb/March 2017 — 0478/22/F/M/17, file 0478_m17_qp_22.pdf.

Advertisement
Loading the paper…
Text of this paper

www.dynamicpapers.com

Cambridge International Examinations
Cambridge International General Certificate of Secondary Education

* 7 7 3 4 2 6 3 8 0 1 *

0478/22

COMPUTER SCIENCE
Paper 2 Problem-solving and Programming

February/March 2017
1 hour 45 minutes

Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.
READ THESE INSTRUCTIONS FIRST
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
Answer all questions.
DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.
You are advised to spend no more than 40 minutes on Section A (Question 1).
No marks will be awarded for using brand names of software packages or hardware.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
The maximum number of marks is 50.

The syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.

This document consists of 10 printed pages and 2 blank pages.
DC (SLM/SW) 134136/3
© UCLES 2017

[Turn over

2

www.dynamicpapers.com

Section A
You are advised to spend no longer than 40 minutes answering this section.
Here is a copy of the pre-release material.
DO NOT attempt Tasks 1, 2 and 3 now.
Use the pre-release material and your experience from attempting the tasks before the examination to
answer Question 1.
Pre-release material
An experiment has taken place which measures the reaction speeds of students. Each student is
aged from 12 to 16, and belongs to a school house (Saturn or Mars). A program is required to store
the age, school house and reaction time of each student in the school. There are 650 students in the
school. The program should be able to output the reaction times of different student groups.
Write and test a program for the school.

•
•
•

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

You will need to complete these three tasks. Each task must be fully tested.
TASK 1 – Set up arrays and store records
Set up one-dimensional arrays for the whole school to store the following data:

•
•
•

The age of each student in whole years
The school house of each student
The reaction time of each student

Input and store the records for an appropriate sample of students. Inputs must be validated on
entry and any invalid inputs rejected.
TASK 2 – Output school house based statistics
Using your sample, calculate and output the average reaction times for students in Saturn and
students in Mars.
TASK 3 – Output statistics based on user input
Extend your program to prompt users to input a specific age and school house. Using only records
that match the criteria input, the program should identify, calculate and output:

•
•

The average reaction time
The slowest reaction time

The output should include a suitable message for each of the reaction times identified.

© UCLES 2017

0478/22/F/M/17

3
1

www.dynamicpapers.com

(a) All variables and other identifiers should have meaningful names.
(i)

Declare the array used to store the reaction times for the whole school.
[1]

(ii)

Change this declaration so the array can only hold records for a sample of 50 students.
[1]

(iii)

Explain why an array is an effective data structure for storing the reaction time records.

[2]

(b) Write an algorithm to complete Task 1 for the whole school, using either pseudocode,
programming statements or a flowchart. DO NOT include any validation routines.

[3]

© UCLES 2017

0478/22/F/M/17

[Turn over

4

www.dynamicpapers.com

(c) Identify three different types of test data you used to test the validation checks on the age
input in Task 1. For each type, give an example of appropriate data.
Type of test data

Example data

[6]
(d) Explain how you calculated and outputted the average reaction time based on the user
inputs of age and school house, as part of Task 3. Any programming statements used in your
answer must be fully explained.

[5]
© UCLES 2017

0478/22/F/M/17

5

www.dynamicpapers.com

(e) Explain how you would change your solution to Task 3 to output the age of the student with
the fastest reaction time.

[2]

© UCLES 2017

0478/22/F/M/17

[Turn over

6

www.dynamicpapers.com

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
02
03
04
05
06
07
08

Num18 = 0
INPUT Age
WHILE Age >= 0 DO
IF Age >= 18 THEN
Num18 = Num18 + Age
ENDIF
ENDWHILE
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

www.dynamicpapers.com

7
3

There is a program that stores the following data:

•
•
•
•

EmployeeID, an employee ID which must be two letters followed by 4 numbers, e.g. TY4587
Manager, whether the employee is a manager or not
AnnualHoliday, number of whole days’ annual holiday
PayGrade, the employee’s pay grade which must be a single letter A–F

Complete the following table to identify:

•
•

The most appropriate data type for each variable
An appropriate validation check for each variable. You must use a different validation check
for each variable.
Variable

Data type

Appropriate validation check

EmployeeID
Manager
AnnualHoliday
PayGrade
[8]

© UCLES 2017

0478/22/F/M/17

[Turn over

www.dynamicpapers.com

8
4

Study the flowchart.
START

INPUT A

IS
A > 0 ?

OUTPUT B

Yes

B
C

A
A

B

B + A

No

C

C – 1
IS
C <= 1 ?

OUTPUT
'Exit'

Yes

No

END
Complete the trace table for the input values 4, 3, −1:
A

B

C

OUTPUT

[4]

© UCLES 2017

0478/22/F/M/17

9
5

www.dynamicpapers.com

(a) Rewrite the following pseudocode algorithm using a WHILE … DO … ENDWHILE loop.
INPUT Num
FOR Counter ← 1 TO 12
Num ← Num * Counter
A[Counter] ← Num
NEXT

[4]
(b) Explain the differences between a WHILE … DO … ENDWHILE and a REPEAT … UNTIL
loop.

[4]

© UCLES 2017

0478/22/F/M/17

[Turn over

www.dynamicpapers.com

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
Date

Purchase
Price ($)

Portable

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

Y

>1000

Sort:
Show:
Criteria:

Ascending
3

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

www.dynamicpapers.com

12

www.dynamicpapers.com

BLANK PAGE

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

© UCLES 2017

0478/22/F/M/17

Advertisement