Sie sind auf Seite 1von 13

Adventist College Phoenix

2nd Term Exams 2015

Upper 6
Computer Science
Paper 2
Time: 2hrs

Name: _____________________
Class: ________________
Examiner: __________________

Throughout the paper you will be asked to write either pseudocode or program code.
Complete the statement to say which high-level programming language you will use.
Programming language used: ............................................

Page 1 of 13

Question 1
A program is to be written to enter and display the first five riders on a mountain top in a
stage of a multiple stage of the Tour De France bike racing competition.
The first rider gets a 30 points bonus.
The second rider gets a 15 points bonus.
The third rider gets a 10 points bonus.
The fourth rider gets a 5 points bonus.
The fifth rider gets a 3 points bonus.
The structured English description of the problem is shown here:
01 Input surname of each rider
02 Input other names of each rider
03 Input position of each rider
04 Input team of player
05 Calculate the bonus points for each rider
06 Store the points in a provisionary table (which will later be added to the
mountains classification table)
07 Repeat step 01 until all 5 riders have been input
Typical output is shown:

Rank

Rider Name

Other Names Team

Points

Froome

Christopher

Sky

30

Pantani

Marco

Carrera

15

Contador

Alberto

Garmin

10

Virenque

Richard

FDJ

Jalabert

Laurent

Once

Page 2 of 13

a)
i. Study the structured english and complete the identifiers table below:

Identifier

Data type

Description

RiderSurname

String

Surname of the rider

[5]
ii.

Explain why the identifier RiderSurname is written in this way

__________________________________________________________________
_______________________________________________________________[1]
iii. Suggest another acceptable way you could have written the identifier
__________________________________________________________________
_______________________________________________________________[1]
b) A record should be used to store details for riders. Write a piece of code in a
programming language for the declaring the record structure.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
_______________________________________________________________ [5]
Page 3 of 13

c) Write program code from this structured English (in page 2)


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
[9]

Page 4 of 13

d) Line 05 in the structured English does not give sufficient details to write program
code from this statement.
Use Stepwise refinement to give detail for line 05.

[5]
Page 5 of 13

Question 2
The rider with the lowest aggregate time is the leader of the race and is on top of general
classification table. At the end of each stage, the time for that stage is added to the table.
The table needs to be sorted again
a)

Complete the pseudocode below that uses bubble sort to


procedure bubbleSort( A as Array )
do
___________ = false
for each i in 1 to length(A) - 1 inclusive do:
if A[i-1].aggregatetime > __________________ then
swap( _____________, A[i] )
swapped = ______________
end if
end for
while swapped
end ________________

[5]
b)

Give two benefits of using procedures.


__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
_______________________________________________________________ [2]

Page 6 of 13

Question 3
The record needs to be stored in a file.
a)
Explain why we need to store data in a file.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
_____________________________________________________________________[1]
(b) Write program code that will store the record of 200 riders in a file call riders.dat.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
_____________________________________________________________________[9]

Page 7 of 13

Question 4
There are different types of riders. The trainer may use the Body Mass Index (BMI) to
determine what category suits mosts to a rider
Among the categories there are
Climbing specialist
puncheur
Sprinter
The formula below is used to get the BMI of a rider

FUNCTION GetBMI ( mass: Integer, height: Real) RETURNS real


1

a) Explain the various parts of the Function header.


1. __________________________________________________________________
__________________________________________________________________
2. __________________________________________________________________
__________________________________________________________________
3. __________________________________________________________________
__________________________________________________________________
4. __________________________________________________________________
________________________________________________________________[4]
b)

This statement is used in pseudocode


GetBMI (80, 1.8)
What value will it return?
_____________________________________________________________[2]

Page 8 of 13

Question 5
A student is experimenting with String manipulation. He testes the following functions in
a program.
Substr

Onechar
CharactercountConcat

Page 9 of 13

CHRASC

The figure below show part of the standard ASCII character codes:

a) He uses the following string variable in his program.


MyString Paper 2 is a difficult paper
Using the substr function, write expressions to return
i. paper
_______________________________________________________________[1]
ii. difficult
_______________________________________________________________[1]

Page 10 of 13

iii. Complete the pseudocode that will return the following:


P
Pa
Pap
Pape
Paper
For count ____ to ____
print ( substr ( _______, _____, _____ ))
next
[5]
b) Use the ascii code table to find the value of
ASC(F) + ASC(P)
_______________________________________________________________[1]
ASC(O) - ASC(K)
_______________________________________________________________[1]

Page 11 of 13

c)

Give the string produced by the following expressions


i. CHR(81) & CHR(85) & CHR(69) & CHR(69) & CHR(78)
_______________________________________________________________[1]
ii. SUBSTR(CHR(66) & CHR(69) & CHR(65) & CHR(84), 2, 4)
_______________________________________________________________[2]
iii. concat (Big, , Ben)
_______________________________________________________________[1]
iv. concat(concat(Mall, of), Mauritius)
_______________________________________________________________[2]
v. concat (CHR(81), , ASC(A))
_______________________________________________________________[2]
vi. CHARACTERCOUNT (Adventist College) + 5
_______________________________________________________________[1]
vii. ONECHAR(Camel, 1) & ONECHAR(Nuts, 2) & ONECHAR(sa, 1) &
ONECHAR(Ki, 2) & ONECHAR(BON, 3) & ONECHAR(sa, 1)

____________________________________________________________[2]

Page 12 of 13

Quesition 6
The students is now experimenting with maths expression. Besides the normal +, -, *
and / expressions he also works with the following:
The expression 17 DIV 7 evaluates to 2
The expression 17 MOD 3 evaluates to 3
The expression ROUND(4.6) evaluates to 5
The expression ROUND(4.2) evaluates to 4
The expression FLOOR(4.6) evaluates to 4
The expression CEILING(4.6) evaluates to 5
Write expressions to find the
a) The sum of 5 and 10
_______________________________________________________________[1]
b) the remainder when 13 is divided by 3
_______________________________________________________________[1]
c) the integreal part of 10.5
_______________________________________________________________[1]
d) 10.8 rounded to the nearest integer
_______________________________________________________________[1]
e) the quotient when 13 is divided by 3
_______________________________________________________________[1]
f) the nearest intgeger greater than 10.2
_______________________________________________________________[1]

Page 13 of 13

Das könnte Ihnen auch gefallen