Sie sind auf Seite 1von 34

5/6/2016

O LEVEL
COMPUTER
SCIENCE
2210

PRACTICE PAPER OF
PRE-RELEASED MATERIAL
MAY/ JUNE 2016

Prepared By: | Tanvir Iqbal Khan

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

In preparation for the examination candidates should attempt the following practical tasks by writing and
testing a program(s).
The manager of a building materials delivery service needs a program to check the contents and weight
of sacks to ensure that correct orders are made up of delivery. A price for the order will be calculated.
Write and test a program for the manager.

You 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.
TASKS 1 Check the contents and weight of a single sack.
Each sack must obey the following rules to be accepted:
Contain cement, gravel or sand with a letter on the side for the easy identification.
C cement
G gravel
S sand
sand or gravel must weigh over 49.9 and under 50.1 kilograms
cement must weigh over 24.9 and under 50.1 kilograms
Input and store the weight and contents for one sack. The contents must be checked and an incorrect
sack rejected. The weight must be validated on entry and an overweight or underweight sack rejected.
Output the contents and weight of an accepted sack. If a sack is rejected, output the reason(s).
TASK 2 Check a customers order for delivery.
Input and store the number of sacks of each type required for the order. Use TASK 1 to check the
contents and weight of each sack. Ensure that the delivery contains the correct number and type of sacks
for the order.
Output the total weight of the order.
Output the number of sacks rejected from the order.
TASK 3 Calculate the price for a customers order.
Extend TASK 2 to calculate a price for an order. Price for the sacks are as follows:

Calculate and output the regular price for the order. Check how many special packs are in the order. If a
discount price applies then output the new price for the order and the amount saved.

regular price for each sack


o cement, $3
o gravel, $2
o sand, $2
discount price for a special pack containing one sack of cement, 2 sacks of sand and 2 sacks of
gravel, $10

Page

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

Author: Tanvir Iqbal Khan

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Subject Specialist O Level Co puter Scie ce


A Level Computing

O LEVEL COMPUTER SCIENCE CIE EXAM MAY/ JUNE 2016


PRE-RELEASED MATERIAL: PAPER 2

SOLUTION IN PSEUDOCODE:
TASK 1 Check the contents and weight of a single sack
Initialization of Variables
SET SackType
SET Weight 0
ET LowerLi it 0
ET UpperLi it 0

Input & Validation of SACK Types


Sack types are: C Cement, G Gravel, S Sand (any other entry will be rejected)
Repeat
Print "Enter sack type: C cement : G gravel : S sand"
Input SackType
If (SackType <> "C" And SackType <> "G" And SackType <> "S") Then
Print "Sack type is rejected"
End If
Until SackType "C" Or SackType "G" Or SackType "S"

Input & Validation of SACKS Weight

Sand or Gravel must weigh over 49.9 and under 50.1 kilograms
Cement must weigh over 24.9 and under 25.1 kilograms

Repeat
Print "Please Enter the sack weight:"
Input Weight
If SackType "C" and Weight <= 24.9 Then
Print "Sacks weight is rejected due to underweight"
ElseIf Weight >= 25.1 Then

Page

EndIf

Print "Sacks weight is rejected due to overweight"

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

LowerLimit 24.9
UpperLimit 25.1
ElseIf SackType "G" Or SackType "S" AND Weight <=49.9 Then
Print "acks weight is rejected due to underweight"
ElseIf Weight >= 50.1 Then
Print "Sacks weight is rejected due to overweight"
End If
LowerLimit 49.9
UpperLimit 50.1
End If
Until Weight > LowerLimit AND Weight < UpperLimit
Print "Content of Sack or Sack Types " , SackType

Page

Print "Sack Weight ", Weight

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

TASK 2 Check a customers order for delivery


Inputs and store the number of sacks of each type required for the orders
Ensure that the delivery contains the correct number of sacks

Initialization of Variables
Counter 0, SackType , Weight 0, TotalNoOfSacks 0, SacksOfCement 0,
SacksOfGravel, 0, SacksOfSand 0, RejectedSackType 0, AcceptedSackType 0

Data Entry of Number of Sacks of each Type


Repeat
Print "Enter total quantity of sacks for Cement"
Input SacksOfCement
Print " Enter total quantity of sacks for Gravel"
Input SacksOfGravel
Print " Enter total quantity of sacks for Sand"
Input SacksOfSand
TotalNoOfSacks SacksOfCement + SacksOfGravel + SacksOfSand
If TotalNoOfSacks <= 0 Then
Print "Invalid quantity"
End If
Until TotalNoOfSacks > 0

Ensure that the delivery contains the correct type of sacks


Output the total weight of the order
Output the number of sacks rejected from the order

Following Loop used for Total No. Of Sacks


Repeat
Validation of Sack Type in Repeat- Until Loop
Repeat

Page

If (SackType <> "C" AND SackType <> "G" And SackType <> "S") Then
Print Sack type rejected"
RejectedSackType RejectedSackType + 1
End If

Print "Enter sack type either C (Cement), G (Gravel) or S (Sand)

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

If SackType C Then
CementCount CementCount + 1
If CementCount > SacksOfCement Then
Print "Sacks of Cement exceeding the limit"
End If
ElseIf SackType "G" Then
GravelCount GravelCount + 1
If GravelCount > SacksOfGravel Then
Print "Sacks of Gravel exceeding the limit"
End If
ElseIf SackType "S" Then
SandCount SandCount + 1
If SandCount > SacksOfSand Then
Print "Sacks of Sand exceeding the limit"
End If
End If
Until (SackType "C" And CementCount <= SacksOfCement) Or (SackType "G" And GravelCount <=
SacksOfGravel) Or (SackType "S" And SandCount <= SacksOfSand)

Validation of Sack Weight in Repeat- Until Loop


Print "Enter the sack weight"
Input Weight
If SackType "C" Then AND Weight <= 24.9 Then
Output "Sack rejected due to underweight"
RejectedSackType RejectedSackType + 1
ElseIf Weight >= 25.1 Then
Print "Sack rejected due to overweight"
RejectedSackType RejectedSackType + 1
Else
TotalWeight TotalWeight + Weight

Page

LowerLimit 24.9
UpperLimit 25.1

End If

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

ElseIf SackType "G" Or SackType "S" AND Weight <= 49.9 Then
Print "Sack rejected due to underweight"
RejectedSackType RejectedSackType + 1
ElseIf Weight >= 50.1 Then
Print "Sack rejected due to overweight"
RejectedSackType RejectedSackType + 1
Else
TotalWeight TotalWeight + Weight
End If
LowerLimit 49.9
UpperLimit 50.1
End If
Until (Weight > LowerLimit) AND (Weight < UpperLimit)
AcceptedSackType AcceptedSackType + 1
Until AcceptedSackType >= TotalNoOfSacks

Page

Print "Total Weight of all Sacks ", TotalWeight


Print "Total No. of Sacks rejected ", RejectedSack
Print "Total No. of Sacks Accepted ", AcceptedSackType

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

TASK 3 Calculate the price for a customers order


Extend Task 2 to calculate a price for an order, prices for the sacks are as follows;

Regular price for each sack


Cement $3, Gravel $2, Sand $2
Discount price for a special pack containing one sack of cement, 2 sacks of sand
and 2 sacks of gravel, $10
Calculate and output the regular price for the order, Check how many special
packs are in the order. If a discount price applies then output the new price for
the order and the amount saved

SET SackType
: Weight 0 : TotalNoOfSack 0 :Counter 0: SacksOfCement 0:
SET SacksOfGravel 0: SacksOfSand 0 :PriceOfCement 3 : PriceOfGravel 2 : PriceOfSand 2
Repeat
Print "Enter No. of sacks of Cement: "
Input SacksOfCement
Print "Enter No. of sacks of Gravel: "
Input SacksOfGravel
Print "Enter No. of sacks of Sand: "
Input SacksOfSand
TotalNoOfSacks acksOfCement + SacksOfGravel + SacksOfSand
If TotalNoOfSacks <= 0 Then
Print Invalid No of Sacks
End If
Until TotalNoOfSacks > 0

Validate Sack Types using Repeat-Until Loop


Repeat

Page

Print "Enter sack type: C cement : G gravel : S sand"


Input SackType
If (SackType <> "C" And SackType <> "G" And SackType <> "S") Then
Print "Sack type is rejected
RejectedSack RejectedSack + 1
End If

Repeat

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

If SackType "C" Then


CementCount CementCount + 1
If CementCount > SacksOfCement Then
Print (Sacks of Cement is exceeding the limit
End If
ElseIf SackType "G" Then
GravelCount GravelCount + 1
If GravelCount > SackOfGravel Then
Print (Sacks of Gravel is exceeding the limit
End If
ElseIf SackType "S" Then
SandCount SandCount + 1
If SandCount > SackOfSand Then
Print (Sacks of Sand is exceeding the limit
End If
End If
Until (SackType "C" And CementCount <= SacksOfCement) Or
(SackType "G" And GravelCount <= SacksOfGravel) Or
(SackType "S" And SandCount <= SacksOfSand)

Validate Weight of Sacks Using Repeat-Until Loop


Repeat
Print "Enter weight of sack")
Input Weight
If SackType C And Weight <= 24.9 Then
Print Sack Type is rejected due to underweight
RejectedSackType RejectedSackType + 1
ElseIf Weight >= 25.1 Then
Print "Sack Type is rejected due to overweight"
RejectedSackType RejectedSackType + 1
Else
TotalWeight TotalWeight + Weight
End If

Page

ElseIf SackType "G" Or SackType "S" AND Weight <= 49.9 Then
Print Sack Type is rejected due to underweight
RejectedSackType RejectedSackType + 1

LowerLimit 24.9
UpperLimit 25.1

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

ElseIf Weight >= 50.1 Then


Print Sack Type is rejected due to overweight
RejectedSackType RejectedSackType + 1
Else
TotalWeight TotalWeight + Weight
End If
LowerLimit 49.9
UpperLimit 50.1
End If
Until (Weight > LowerLimit AND (Weight < UpperLimit)
AcceptedSacks AcceptedSacks + 1
Until AcceptedSacks TotalNoOfSack
TotalPrice (SacksOfCement * PriceOfCement) + (SacksOfGravel * PriceOfGravel) + (SacksOfSand *
PriceOfSand)

Repeat
If SacksOfCement >= 1 And SacksOfGravel >= 2 And SacksOfSand >= 2 Then
SpecialPack SpecialPack + 1
SacksOfCement SacksOfCement - 1
SacksOfGravel SacksOfGravel - 2
SacksOfSand SacksOfSand - 2
End If
Until SacksOfCement < 1 Or SacksOdGravel < 2 Or SacksOfSand < 2
Print "Price for Total Orders ", TotalPrice , "$"

Page

If SpecialPack > 0 Then


DiscountedPrice (SpecialPack * 10) + (SacksOfCement *
PriceOfCement) + (SacksOfGravel * PriceOfGravel) + (SacksOfSand *
PriceOfSand)
AmountSaved TotalPrice - DiscountedPrice
Print "New price after discount ", DiscountedPrice, "$"
Print "Amount Saved ", AmountSaved , "$"
End If

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

TASKS 1 Check the contents and weight of a single sack.


Each sack must obey the following rules to be accepted:
Contain cement, gravel or sand with a letter on the side for the easy identification.
C cement
G gravel
S sand
sand or gravel must weigh over 49.9 and under 50.1 kilograms
cement must weigh over 24.9 and under 50.1 kilograms
Input and store the weight and contents for one sack. The contents must be checked and an incorrect
sack rejected. The weight must be validated on entry and an overweight or underweight sack rejected.
Output the contents and weight of an accepted sack. If a sack is rejected, output the reason(s).

INPUT Sack// contents of sack


INPUT Weight
Case Sack OF
C :
IF (Weight > 24.9) AND (Weight < 25.1)
THEN PRINT Sack accepted: , Sack, Weight, kg
ELSE PRINT Sack rejected: Weight out of range
ENDIF
G", S":
IF (Weight > 49.9 AND (Weight < 50.1)
THEN PRINT Sackaccepted: , Sack, Weight, kg
ELSE PRINT Sack rejected: Weight out of range
ENDIF
OTHERWISE: PRINT Error: sack does t exist
TASK 2 Check a customers order for delivery.
Input and store the number of sacks of each type required for the order. Use TASK 1 to check the
contents and weight of each sack. Ensure that the delivery contains the correct number and type of sacks
for the order.

Page

CLower < - 24.9, cUpper , <- 25.1


gsLower , <- 49.9, gsUpper <- 50.1
Sack[3] <- [ cement , gravel , sand ]
sackLetter[3] <- [ C , G , S ]
totalWeight <- 0
rejected <- 0

10

Output the total weight of the order.


Output the number of sacks rejected from the order

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

FOR I <- 1 to 3
PRINT How many , sack[i], sacks?
INPUT sackNumber
FOR j <- 1 to sackNumber
PRINT Enter weight of sack# , j, :
INPUT Weight
CASE sackLetter[i] OF
C :
IF (Weight > cLower) AND (Weight <Upper)
THEN PRINT TotalWeight <- TotalWeight + Weight
ELSE rejected < rejected + 1
ENDIF
G , S :
IF (Weight > gsLower) AND (Weight gsUpper)
THEN TotalWeight <- + Weight
ELSE rejected <- rejected +1
ENDIF
OTHERWISE: PRINT Error: sack does t exist
ENDCASE
NEXT j
NEXT i

Page

11

PRINT Total Weight: , TotalWeight, kg


PRINT Rejected: , rejected

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

Author: Tanvir Iqbal Khan

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Subject Specialist O Level Co puter Scie ce


A Level Computing

TASK 3 Calculate the price for a customers order.


Extend TASK 2 to calculate a price for an order. Price for the sacks are as follows:

regular price for each sack


o cement, $3
o gravel, $2
o sand, $2
discount price for a special pack containing one sack of cement, 2 sacks of sand and 2 sacks of
gravel, $10

Calculate and output the regular price for the order. Check how many special packs are in the order. If a
discount price applies then output the new price for the order and the amount saved.

cLower < 24.9, cUpper <- 25.1


gsLower <- 49.9, gsUpper <- 50.1
Sack[3] <- [ cement , gravel, sand ]
sackLetter[3] <- [ C , G , S ]
TotalWeight <- 0
Rejected <- 0
cPrice <- 3
gsPrice <- 2
Quants[3]
TotalPrice <- 0
specialPacks <- 0
FOR I <- 1 to 3
PRINT How many , sack[i], sacks?
INPUT sackNumber
Quants[1] <- sackNumber

Page

G , S :
IF (Weight > gsLower) AND (Weight < gsUpper)
THEN
TotalWeight < TotalWeight + Weight
TotalPrice <- TotalPrice +gsPrice

12

FOR j <- 1 to sackNumber


PRINT Enter weight of sack # , j, :
INPUT Weight
CASE sackLetter[i] OF
C :
IF (Weight > cLower) AND Weight < Upper)
THEN
TotalWeight <- TotalWeigt + Weight
TotalPrice <- TotalPrice + cPrice
ELSE rejected <- rejected + 1
ENDIF

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

ELSE rejected <- rejected + 1


ENDIF
OTHERWISE: PRINT Error: sack does t exist
ENDCASE
NEXT j
NEXT i
PRINT Total weight: , TotalWeight, kg
PRINT Rejected , rejected
WHILE quants[i] >= 1 AND quants[2] >= 2 AND quants[3] >= 2 DO
specialPacks <- specialPacks + 1
Quants[1] <- quants[1] 1
Quants[2] <- quants[2] - 2
Quants[3] <- quants[3] 2
ENDWHILE
finalPrice <- totalPrice specialPacks * 11 + specialPacks * 10
amountSaved <- totalPrice finalPrice

13

Regular price: $ , totalPrice


specialPacks , specialPacks
Final price: $ , finalPrice
Amount saved: $, amountSaved

Page

PRINT
PRINT
PRINT
PRINT

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

1. (a) All variables, constants and other identifiers should have meaningful names.
(i) Variables/ Identifiers/ fields are used to store data that belongs to different data
types.
Write three suitable declarations of fields, its data type and use of each field in TASK 1
and TASK 3
#

Fields

Data types

Use

1
2
3
[3]
(ii) Constants are used in TASK 2 and TAKS 3.
Write suitable declarations for two of these.
State what you used each one for.
Constant 1......................................................................................................
Use...................................................................................................................

........................................................................................................................
Constant 2.........................................................................................................
Use...................................................................................................................

.....................................................................................................................[4]
(b) All variables, constants and other identifiers should have meaningful names.
(i) Declare the array to store the Contents (cement, gravel and sand).

.....................................................................................................................[1]
(ii) Declare the array to store the Contents weights.

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

dimensional arrays.

Page

of Cement and 50 Sacks of Gravel. Both types of sacks are being recorded in one

14

(iii) The manager of building material delivery service has received order for 100 sacks

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

Write suitable new declarations for these two arrays.

........................................................................................................................
..................................................... ...............................................................[1]
(iv) Comment on the efficiency of your design for TASK 3.

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

Page

15

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(c) Write an algorithm to complete Task 1, using either pseudocode, programming


statements or a flowchart.

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

Page

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

16

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(d) Write an algorithm to complete Task 2, using either pseudocode, programming


statements or a flowchart. Record total number of sacks of each type to validate its total
quantity if it is zero or below zero an error message should be shown. You should
assume that Task 1 has already been completed.

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

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

Page

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

17

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(e) Write a statement in pseudocode that calculates total price of all sacks in TASK 3.

.............................................................................................................................. ......
....................................................................................................................................
[1]
....................................................................................................................................
(f) (i) Show two different sets of building material data that you could use to check the
validation used in Task 2. Explain why you chose each data set.
Set 1.............................................................................................................................
Reason for choice.........................................................................................................

....................................................................................................................................
....................................................................................................................................
Set 2.............................................................................................................................
Reason for choice.........................................................................................................

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

.... ................................................................................................................................
(ii) Describe suitable validation rules for Task 1.

....................................................................................................................................
...................................................................................................................................
[1]
......................................................................... ...........................................................
(iii) How can you show rejected number of sack types if weight doesnt match the lower
and upper weight criteria in TASK 3, using pseudo code or flowchart.

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

2. The following pseudocode algorithm should:

Page

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

18

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

input up to 20 numbers
stop if the sum of the input numbers exceeds 50
output the final sum
10 count = 0
20 REPEAT
30 INPUT n
40 n + sum = sum
50 IF sum = 50 THEN count = 20
60 count = count + 1
70 UNTIL count = 20
80 OUTPUT n
There are five errors in this algorithm.
Locate these errors and suggest a correction.
Error 1..........................................................................................................................

....................................................................................................................................
Correction 1..................................................................................................................

....................................................................................................................................
Error 2..........................................................................................................................

....................................................................................................................................
Correction 2..................................................................................................................

....................................................................................................................................
Error 3..........................................................................................................................

....................................................................................................................................
Correction 3..................................................................................................................

Page

Error 4..........................................................................................................................

19

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

....................................................................................................................................
Correction 4..................................................................................................................

....................................................................................................................................
Error 5..........................................................................................................................

....................................................................................................................................
Correction 5..................................................................................................................

Page

20

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

3. (a) The following pseudocode was written to input 1000 dates.


1
2
3
4
5
(i)

count = 1
repeat
input day, month, year
count = count + 1
until count = 1000
Describe why the loop only inputs 999 dates instead of 1000.

.....................................................................................................................
.....................................................................................................................
.................................................................................................................. [1]
(ii)

What needs to be changed or added to the above code to make sure 1000
dates are input?

.....................................................................................................................
.....................................................................................................................
.................................................................................................................. [1]
(b) Errors in code can be found using test data.
Name three different types of test data. Using month from the pseudocode above,
give an example of each type of test data.
test data type 1.....
example .......

....
test data type 2.....
example .......

......
test data type 3.....

Page

... [6]

21

example .......

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

4. (i) Weight of a sack of a particular content such as Cement, Gravel and Sand is being
recorded using weighing machine. The sacks of Cement and Gravel must weigh under
50.1 kilograms and over 49.9 kilograms. The weigh over 50.1 is rejected and weigh of
sacks below 49.9 kilograms are also rejected.
Give an example of each type of test data for this routine.
Normal..............................................................................................................
Extreme.........................................................................................................
Abnormal ....................................................................................................... [3]
(ii) Identify two different conditional statements that you can use when writing
pseudocode.
1.......................................................................................................................

Page

22

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

5. The following flowchart inputs ten temperatures and outputs the average (mean)

Page

23

temperature and the number of temperatures which were negative (i.e. < 0).

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(a) Complete the trace table for this flowchart using the following test data:
5, 11, 16, -4, -10, 8, 10, -3, 17, 10

[4]
(b) What values are outputs from the flowchart using the above test data?

Page

24

.[1]

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

Page

25

6. (a) A floor turtle uses the following instructions:

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

Complete the following set of instructions to draw the shape in the direction shown by
the arrows.

Page

26

[4]

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(b) The following set of instructions can be used to control a robot which moves heavy
boxes.

The following set of instructions moves the robot forward 20 steps, turns the robot 90
anti-clockwise and moves the arms up 40cm.

.
.
.[1]
Forward 20
Left 90
Up 40

Page

27

Write three more instrutions so that the robot will return to its original state.

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

7. Four programming concepts and four examples of programming code are shown below.
Draw a line to link each programming concept to the correct example of programming
code.

(a) Write an algorithm, using pseudocode and a FOR TO NEXT loop structure, to
input Wight of 500 students into an array.

.
.
.
.
.

Page

28

.[2]

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(b) Rewrite your algorithm using another loop structure.

.
.
.
.
.
.
.
.

Page

29

.[4]

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

8. A customer wants to compare prices of 1000 items sold in two supermarkets (price1 and
price2).
Write an algorithm, using pseudocode or a flowchart, which:
inputs the two prices for all 1000 items
outputs how many items were more expensive in supermarket 1
outputs how many items were more expensive in supermarket 2
outputs the largest price difference.

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

Page

..[5]

30

..

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

9. A shop keeps its stock file on a computer system. Part of the file is shown in the diagram
below:

The following codes have been used.


B = Black G = Green R = Red S = Silver
(a) State how many records are shown in the diagram.
............................................................................................................................................ [1]
(b) State two advantages of coding the data in the COLOUR field.
1. ...............................................................................................................................................

2. ..
..[2]
(c) State the data type that should be used for the WEIGHT (KG) data.
...............................................................................................................................................[1]
(d) State one advantage of using fixed-length records for storing the data.
...............................................................................................................................................[1]
(COLOUR NOT B) AND (WEIGHT (KG) < 2.0)
......................................................................................................................................................[2]

Page

31

(e) Which STOCK NO data will be listed if the following search condition is input?

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

(f) Write down a search condition that will search for all the items with less than 16 in
stock and the price is more than $100.
.................................................................................................................................................... [2]
(g) State which field should be used to link this stock file to a supplier file. Give a reason
for your choice of field.
Field..................................................................................................................................................
Reason.............................................................................................................................................
......................................................................................................................................................[2]
10. 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.

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

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

Page

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

32

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

SYLLABUS CODE: 22101/02

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Co puter Scie ce
A Level Computing

Price in $ .......................................................................................................[3]
(d) The query-by-example grid below selects all houses with more than 1 bathroom and
more than 2 bedrooms.

Show what would be output.

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

Page

33

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

Website: sirtanviriqbalkhan.tk
Facebook: www.facebook.com/tanvirik
Email: tanviriqbalkhan@gmail.com

PHONE: +923212490887

Das könnte Ihnen auch gefallen