Вы находитесь на странице: 1из 20

5/21/2015

O LEVEL
COMPUTER
SCIENCE
2210

PRACTICE PAPER OF
PRE-RELEASED MATERIAL 2015

Prepared By: | Tanvir Iqbal Khan

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

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 Section A Question 1.
TASK 1
A school keeps records of the weights of each pupil. The weight, in kilograms, of each pupil is
recorded on the first day of term. Input and store the weights and names recorded for a class of
30 pupils.
You must store the weights in a one-dimensional array and the names in another onedimensional array.
All the weights must be validated on entry and any invalid weights rejected. You must decide
your own validation rules. You may assume that the pupils names are unique. Ouput the names
and weights of the pupils in the class.
TASK 2
The weight, in kilograms, of each pupil is recorded again on the last day of term. Calculate and
store the difference in weight for each pupil.
TASK 3
For those pupils who have a difference in weight of more than 2.5 kilograms, output, with a
suitable message, the pupils name, the difference in weight and whether this is a rise or fall.

Page

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

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

PHONE: +923212490887

Author: Tanvir Iqbal Khan

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Subject Specialist O Level Computer Science


A Level Computing

O LEVEL COMPUTER SCIENCE CIE EXAM 2015


PRE-RELEASED MATERIAL: PAPER 2
SOLUTION: Algorithm
Initialization of Variables
1. Set Name =
2. Set NameCount = 0
3. Set WeightFirstDay = 0
4. Set WeightCountFirstDay = 0
5. Set WeightLastDay = 0
6. Set WeightCountLastDay = 0
7. Set WeightDifference = 0
8. Set WeightDifferenceCount = 0

Loop for First Day Name & Weight if 30 Students


9. For PupilCount = 1 to 30
10. Print Enter Pupils Name
11. Input Name
12. NameCount(PupilCount) = Name
13. Print Pupils First day weight
14. Input WeightFirstDay

Data Validation for Invalid Weight


15. If WeightFirstDay > 15 AND WeightFirstDay < 100 Then
16. WeightCountFirstDay (PupilCount) = WeightFirstDay
17. Else
18. Print Invalid Weight
19. Input WeightFirstDay

22. Next PupilCount

Page

21. End If

20. WeightCountFirstDay (PupilCount) = WeightFirstDay

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

Loop For Input Weight For Last Day


23. For PupilCount = 1 to 30
24. Print Enter Pupils last day weight"
25. Input WeightLastDay
26. WeightCountLastDay (PupilCount) = WeightLastDay

Equation is used to calculate Weight Difference between First Day & Last Day
27. WeightDifference = WeightLastDay (PupilCount) WeightCountFirstDay (PupilCount)
28. WeightDifferenceCount (PupilCount) = WeightDifference
Data Validation For Weight Difference if more than 2.5 Kilogram
29. If WeightDifferenceCount (PupilCount) > 2.5 Then
Display appropriate message along with Name & Weight Difference if Weight Difference is
found more than 2.5 Kilogram on last day
30. Print NameCount (PupilCount), WeightDifferenceCount (PupilCount), Rise in Weight
31. Else if WeightCountLastDay(PupilCount) < WeightCountFirstDay (PupilCount)
32. Print NameCount (PupilCount), WeightDifferenceCount (PupilCount), Fall in Weight

Display Students Name whose Weight difference is same as First Day


33. Else If WeightDifference = 0 or WeightDifference < 2.5 Then
34. Print NameCount (PupilCount), WeightCountFirstDay (PupilCount)
35. End If

Page

36. Next PupilCount

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

PHONE: +923212490887

Author: Tanvir Iqbal Khan

SYLLABUS CODE: 22101/01

Subject Specialist O Level Computer Science


A Level Computing

O LEVEL COMPUTER SCIENCE

SOLUTION:
Programming Language (Visual Basic 6.0)
Declaration of Variables
Dim StudentName(1 To 3) As String
Dim StudentWeight(1 To 3) As Single
Dim WeightDifference(1 To 3) As Single
Dim STName As String
Dim count, Weight, Difference, PreviousWeight As Single
Initialization of Variables
STName = ""
count = 0
Weight = 0
Difference = 0
PreviousWeight = 0
Input Students Name and Weight in One Dimensional Array on First Day of the Term for 30
Students
For count = 1 To 30
STName = InputBox("Enter Student Name", "First day of the term")
StudentName(count) = STName
Weight = InputBox("Enter Student Weight in KG", "First day of the term")
Validation check to restrict invalid Weight
If Weight > 10 And Weight <= 100 Then
StudentWeight(count) = Weight
Else
MsgBox "Invalid Weight "
Weight = InputBox("Enter Valid Student Weight in KG", "First day of the term")
StudentWeight(count) = Weight
End If
Next count
Output all students Name and Weight from First Day of the Term

Page

For count = 1 To 30
MsgBox StudentName(count) & " " & StudentWeight(count), , "First day of the term"
Next count

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

Input Students Weight for Last Day of the Term


For count = 1 To 30
PreviousWeight = StudentWeight(count)
Weight = InputBox("Enter Student Weight in KG", "Last day of the term")
StudentWeight(count) = Weight

Calculate Difference between Fist Day Weight and Last Day Weight of the Term
Difference = Val(StudentWeight(count)) - Val(PreviousWeight)
WeightDifference(count) = Difference

Validation Check if the Difference is 2.5 Kg or above


If Val(WeightDifference(count)) >= 2.5 Then
MsgBox StudentName(count) & " has gained " & WeightDifference(count) & "KG", , "Last day of the
term"
ElseIf Val(WeightDifference(count)) <= -2.5 Then
Remove minus value of Difference to make result Positive

Page

MsgBox StudentName(count) & " has lost " & WeightDifference(count) * -1 & "KG", , "Last day of the
term"
End If
Next count

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

1. (a) All variables, constants and other identifiers should have meaningful names.
(i) Declare the array to store the students names.

For
Examiners
Use

...............................................................................................................................
(ii) Declare the arrays to store each students weight and weight difference.

...............................................................................................................................
...............................................................................................................................
(b) (i) Show the design of your algorithm to complete Task 1 and Task 2 using
pseudocode, programming statements or a flowchart. Do not include any of the
validation checks in your algorithm.

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

Page

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

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

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

(ii) Comment on the efficiency of your design.

....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
(c) Show two different sets of student data that you could use to check the validation
used in Task 1. Explain why you chose each data set.
Set 1.............................................................................................................................
Reason for choice.........................................................................................................

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

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

Page

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

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

(d) (i) Explain how you select the student with the Weight rise or Weight fall (Task 3).
You may include pseudocode or programming statements to help illustrate your
explanation.

....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
(ii) How does your program work when there is weight of a student having no change?
Explain using your method given in part (d)(i).

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

Page

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

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

2. A golf course charges $10 for each game of two people. Each additional person incurs a
further charge of $2 per game. If they book two or more games in advance, they get a
10% discount on the total charge.
The following program has been written in pseudocode to calculate the charges for a
game.
1 extracost = 0
2 input numberpeople, numbergames
3 charge = 10 * numbergames
4 extrapeople = numberpeople 2
5 if numberpeople < 2 then extracost = 2 * extrapeople * numbergames
6 charge = extracost
7 if numbergames > 1 then charge = charge * 0.1
8 print charge
There are three errors in the program. Locate these errors and suggest a correct piece
of coding.
Error 1..........................................................................................................................

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

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

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

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

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

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

Page

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

(b) What type of validation check is being carried in line number 5 and 7?

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

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


1

count = 1

repeat

input day, month, year

count = count + 1

until count = 1000

(i)

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

.....

... [6]

Page

example .....

10

test data type 3....

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

4. A piece of pseudocode was written to input 1000 positive numbers and then output the
highest and lowest numbers.
10 highest = 0
20 lowest = 0
30 for count = 1 to 100
40

input number

50

if number > highest then number = highest

60

if number < lowest then number = lowest

70

count = count + 1

80 next count
90 print highest, lowest

There are errors in the code.

Locate these errors and suggest a correction.


Error 1..

.
.
Correction.

.
.
Error 2..

.
.
Correction.

Error 3..

Page

11

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

.
.
Correction.

.
.
Error 4..

.
.
Correction.

Page

12

[8]

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

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

Page

13

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/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
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

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

Page

14

..[1]

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

6. A floor turtle uses the following commands:

Page

15

In the following grid, each of the squares represents 10 cm by 10 cm:

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

Complete the set of instructions to draw the shape shown on the left:
1 PENDOWN
2 LEFT 90
3 REPEAT 2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Page

16

[6]

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

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

17

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

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
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.
..................................................................................................................................................... [3]
(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.............................................................................................................................................

Page

18

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

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

PHONE: +923212490887

SYLLABUS CODE: 22101/01

O LEVEL COMPUTER SCIENCE

Author: Tanvir Iqbal Khan


Subject Specialist O Level Computer Science
A Level Computing

VERY IMPORTANT:
Students are strongly advised to follow instructions written below.
1. Practice on each section of the algorithm of page 2 of this Pre-released materials
Practice Question Paper
2. Practice on topic Program flowchart of Past Papers (2011 2014 all May and October
papers) from previous syllabus Computer Studies 7010.
3. Practice on topic Logo Programming of Past Papers (2011 2014 all May and October
papers) from previous syllabus Computer Studies 7010.
4. Practice on topic Database of Past Papers (2011 2014 all May and October papers)
from previous syllabus Computer Studies 7010.

Your valued & precious feedback and suggestions are always appreciated.

GOOD LUCK!

Page

19

Sir Tanvir Khan

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

PHONE: +923212490887

Вам также может понравиться