0% found this document useful (0 votes)
85 views14 pages

Cambridge International General Certificate of Secondary Education

Uploaded by

Anonymous . Com
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)
85 views14 pages

Cambridge International General Certificate of Secondary Education

Uploaded by

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

This exam is modified and contains

new questions for the new syllabus.


Mr. Mahmoud Moussa
01098569912
www.mahmoudmoussa.com
Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 7 8 3 1 6 9 9 9 2 5 *

COMPUTER SCIENCE 0478/21


Paper 2 Problem-solving and Programming May/June 2016
1 hour 45 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.

READ THESE INSTRUCTIONS FIRST

Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.

Answer all questions.

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

Note: This exam has more than 75.

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

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

DC (LEG/SW) 106771/3
© UCLES 2016 [Turn over
2

1 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


3

2 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


4

3 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


5

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


6

4 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


7

5 A database table, STAFFPHONE, was set up to show the telephone extension numbers for members of
staff working in a department store.

Name Department ExtensionNumber


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) Write SQL statements to provide a list of all members of staff, in alphabetical
order, grouped by department.
...........................................................................................................................................

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

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

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

© UCLES 2016 0478/21/M/J/16


8

6 Shop customers have a discount card with a unique card number. Customers collect points after
they have bought items. The more points they have, the bigger the discount. If they shop on a
Wednesday, their discount is increased by 20%.

The function GetDiscountRate() takes a card number as a parameter and returns the discount
rate for a customer based on the number of points they have collected. A flowchart for the function
is shown.

The function uses the following variables and functions.

Identifier Data type Description


DRate REAL The discount rate
CardNum STRING The unique customer card number
Points INTEGER The number of points collected
Takes the card number as a parameter and returns the
GetPoints() FUNCTION
number of points already collected
Today() FUNCTION Returns the day number: 1 for Monday, 2 for Tuesday etc.

START

DRate 0

Points
GetPoints(CardNum)

Is YES
Points > 199 ? DRate 0.2

NO

Is YES
Points > 99 ? DRate 0.1

NO

Is Today = YES DRate DRate * 1.2


Wednesday ?

NO

RETURN DRate

END
9

(a) Write pseudocode to implement the GetDiscountRate() function.

Your solution should follow the flowchart for the function as closely as possible. Variable
declarations should be included.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[8]
10

(b) A programmer writes the function GetDiscountRate() in a high-level language.

(i) A run-time error could occur when the function is used.

Name and describe one other type of error that the function could contain.

Name .................................................................................................................................

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

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

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

(c) There are different ways to minimise the risk of errors when writing programs, such as the
use of constants and library routines.

(i) Identify two values that could be replaced by constants in the function
GetDiscountRate().

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

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

(ii) Write pseudocode to declare one of the constants you have given in part (c)(i).

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

(iii) Explain how the use of constants helps to minimise programming errors.

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

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

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

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

(iv) Give a reason why the use of library routines helps to minimise the risk of errors when
writing a program.

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

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

(v) Constants and library routines help to minimise the risk of errors.

Name another way that you can minimise the risk of errors when writing a program.
Explain how this helps.

Name .................................................................................................................................

Explanation .......................................................................................................................

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

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

7 (a) The following table contains statements written in pseudocode.

Show what type of programming construct each statement represents.

Put a tick (3) in the appropriate column for each statement.

Repetition
Statement Selection Assignment
(Iteration)
WHILE Count < 20
Count Count + 1
IF MyGrade <> 'C' THEN
Mark[Count] GetMark(StudentID)
ELSE OUTPUT "Fail"
ENDWHILE
[6]

(b) (i) The following table contains statements written in pseudocode.

Give the most appropriate data type for the variable used in each statement.

Statement Data type


MyAverage 13.5
ProjectCompleted TRUE
Subject "Home Economics"
MyMark 270
MyGrade 'B'
[5]

(ii) The following table contains statements written in pseudocode.

Complete the table by evaluating each expression using the values from part (b)(i).

If any expression is invalid, write “ERROR” in the Evaluates to column.

Expression Evaluates to
SUBSTRING(Subject, 7, 3)
INT(MyAverage / 2)
ProjectCompleted AND MyMark > 270
ProjectCompleted OR MyMark > 260
LENGTH (MyGrade / 3)
[5]
13

8 (a) Complete the Boolean expession that corresponds to the following truth table.

INPUT OUTPUT
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

X = .......................................................................................................................

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

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

9 (a) A multi-user computer system stores information about users. It uses a 1D array,
UserNameArray, of type STRING. There are 100 elements in the array.

The format of the string in each element of the array is as follows:

<UserID><UserName>

• UserID is a six-character string of numerals.


• UserName is a variable-length string.

Write pseudocode for a procedure, BubbleSort, to perform an efficient bubble sort on


UserNameArray. The array is to be sorted in ascending order of UserID.

You should assume that UserNameArray has been declared as a global variable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...................................................................................................................................................
[15]

You might also like