0% found this document useful (0 votes)
299 views

Computer Science Paper 2 Final Revision Questions - 2017

This document contains a series of questions related to computer science concepts. Question 1 involves identifying the appropriate data type and validation check for variables stored in an employee database. Question 2 involves rewriting a for loop as a while loop and explaining the differences between while and repeat loops. Question 3 involves writing algorithms to input and output data from arrays using for and repeat loops. Question 4 involves choosing an appropriate data structure to store hourly temperature readings, writing an algorithm to count integer values in an input array, and describing test data.

Uploaded by

brighton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
299 views

Computer Science Paper 2 Final Revision Questions - 2017

This document contains a series of questions related to computer science concepts. Question 1 involves identifying the appropriate data type and validation check for variables stored in an employee database. Question 2 involves rewriting a for loop as a while loop and explaining the differences between while and repeat loops. Question 3 involves writing algorithms to input and output data from arrays using for and repeat loops. Question 4 involves choosing an appropriate data structure to store hourly temperature readings, writing an algorithm to count integer values in an input array, and describing test data.

Uploaded by

brighton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Name:............................................................................................................... Class:.................

Computer Science Revision Questions

1 There is a program that stores the following data:

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

Complete the following table to identify:

The most appropriate data type for each variable


An appropriate validation check for each variable. You must use a different validation check
for each variable.

Variable Data type Appropriate validation check

EmployeeID

Manager

AnnualHoliday

PayGrade

[8]

2 (a) Rewrite the following pseudocode algorithm using a WHILE DO ENDWHILE loop.

INPUT Num
FOR Counter 1 TO 12
Num Num * Counter
A[Counter] Num
NEXT

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[4]
3 (a) Write an algorithm, using pseudocode and a FOR TO NEXT loop structure, to input
1000 numbers into an array.
...................................................................................................................................................

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

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

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

...............................................................................................................................................[3]

(b) Rewrite your algorithm using Repeat ....... Until Loop.


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

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

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

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

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

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

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

(c) Write an algorithm, using pseudocode and a FOR TO NEXT loop structure, to output
1000 Names of student from an array.
...................................................................................................................................................

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

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

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

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

...............................................................................................................................................[3]
4(a) A programmer writes a program to store a patients temperature every hour for a day.

State the data structure that would be most suitable to use and give the reason for your choice.

Data structure ...................................................................................................................................

Reason ..............................................................................................................................................

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

(b) Write an algorithm, using pseudocode or flowchart only, which:

inputs 1000 numbers


outputs how many of these numbers were whole numbers (integers)
(You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)

[4]

(c) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]
Use the pre-release material and your experience from attempting the tasks before the examination to
answer Question 1.

1(a) Write an algorithm to complete Task 3, using either pseudocode, programming statements
assuming Task 2 is completed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(b) Give three different data sets that could be used to check your validation rules for Task 1.
Explain why you chose each data set.

Data set 1 ..................................................................................................................................

Reason for choice ......................................................................................................................

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

Data set 2 ..................................................................................................................................

Reason for choice ......................................................................................................................

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

Data set 3 ..................................................................................................................................

Reason for choice ......................................................................................................................

...............................................................................................................................................[6]
(b) (ii) Describe suitable validation rules for Task 1.

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

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

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

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

c) Show the design of your algorithm to complete Task 1 using pseudocode,


programming statements or a flowchart. Do not include any of the validation checks or
input prompts in your algorithm.

[8]

2 Identify two different selection statements that you can use when writing pseudocode.

1 ........................................................................................................................................................

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

2 ........................................................................................................................................................

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

6 A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.

Device ID Device Type User Purchase Purchase Portable


Date Price ($)
3 Desktop Alan Swales 14/02/2017 1350.00 N

4 Laptop Chantel Law 01/02/2016 1460.00 Y

5 Tablet Abdula Saud 31/12/2016 1000.00 Y

6 Desktop Abdula Saud 14/03/2017 1000.00 N

7 Laptop Alan Swales 15/03/2016 1700.00 Y

8 Tablet Taona Jaji 16/12/2016 470.00 Y

(a) The query-by-example grid below selects certain records.

Field: User Portable Purchase Price ($)

Table: DEVICE DEVICE DEVICE

Sort: Ascending

Show: 3

Criteria: Y >1000

or:

Show what would be the output from the query-by-example.

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

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

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

(b) Complete the query-by-example grid below to select all Desktop devices that were either
purchased before 31/12/2016 or cost under $1000. Only show the Device ID and Device
Type.

Field:

Table:

Sort:

Show:

Criteria:

or:
[4]
Answers
3 1 mark for each correctly completed element of the grid 8

Variable Data Type Appropriate Validation Check


EmployeeID String Length Check / Presence Check /
Format Check / Type check
Manager Boolean Type Check / Presence Check
AnnualHoliday Integer Type Check / Range Check / Presence
Check
PayGrade Char Presence Check / Length Check / Type
Check

5(a) initialising counter outside the loop 4


updating counter inside loop
suitable exit value at start of loop
correct use of WHILE DO ENDWHILE

Example:

INPUT Num
Counter 1
WHILE Counter <= 12 DO
Num Num * Counter
A [Counter] Num
Counter Counter + 1
ENDWHILE

5(b) WHILE has criteria check at start / pre-test 4


may never run
REPEAT UNTIL has criteria check at end / post-test
will always run at least once

6(a) Alan Swales Chantel Law 2

Correct data
Correct order

6(b) Field: Device ID Device Type Purchase Date Purchase 4


Price ($)
Table: DEVICE DEVICE DEVICE DEVICE
Sort:
Show: ; ;
Criteria: Like Desktop <#31/12/2016#
or: <1000
1 mark for each correct column
5 (a) 1 mark for FOR TO NEXT 1 mark for INPUT
FOR Count  1 TO 1000
INPUT A[Count]
NEXT (Count) [2]

(b) 4 marks
initialisation
start of loop
update loop counter
end of loop

Example1
Count  1 (1 mark)
REPEAT (1 mark)
INPUT A[Count]
Count  Count + 1 (1 mark)
UNTIL Count > 1000 (1 mark)

Example2
Count  0 (1 mark)
WHILE Count < 1000 (1 mark)
DO
Count  Count + 1 (1 mark)
INPUT A[Count]
ENDWHILE (1 mark)
[4]
5 data structure (onedimensional) array .
.Reason to simplify programming/ make programs shorter/index can be used
to identify the same member across the arrays etc.
[2]

6 IF ( THEN ELSE ENDIF)

CASE ( OF OTHERWISE ENDCASE) [2]

(b) marking points:


loop construct 1 mark
check if number is an integer 1 mark
counting the number of integers input 1 mark
output count value (outside the loop) 1 mark

sample algorithm:
FOR x 1 TO 1000 (1 mark)
INPUT Number
Difference INT(number) Number (1 mark)
IF Difference = 0 THEN Total Total + 1 (1 mark)
NEXT x
PRINT total (1 mark)
(NOTE: alternative to lines 3 and 4:
IF INT(Number) = Number THEN Total Total + 1 (2 marks) ) [4]

(c) Description of any two sets of test data. Many correct answers, these are examples only.

1000 whole numbers to ensure that loop works properly

900 whole numbers and 100 numbers with decimal places to ensure that the routine
distinguishes correctly [2]
(b) 1 mark for the data set and 1 mark for the matching reason all, data sets and reasons must
be different. There are many possible correct answers these are examples only.

Data set 30, 29, 28, 4


Reason normal data; parcel should be accepted

Data set 80, 60, 60, 10


Reason boundary data; parcel should be accepted

Data set 85, 60, 60, 11


Reason abnormal data; parcel should be rejected [6]

1(c) outside loop zeroing total for loop (sum in example below)
loop for all students
input name and all test scores
in loop adding a students total
storing the total
inside loop printing students name and total
outside loop calculating class average
printing class average

sample algorithm:

Sum  0
FOR Count  1 TO 30
INPUT Name
StudentName[Count]  Name
INPUT Mark1, Mark2, Mark3
StudentMarksTest1[Count]  Mark1
StudentMarksTest2[Count]  Mark2
StudentMarksTest3[Count]  Mark3
Total  Mark1 + Mark2 + Mark3
StudentTotalScore[Count]  Total
Sum  Sum + Total
PRINT StudentName[Count], StudentTotalScore[Count]
NEXT Count
ClassAverage = Sum/30
PRINT ClassAverage [8]

(c) (i) any two from


check that the weights are within a given range
check that the weights are numeric
check that the weights are given to one decimal point
character/type check on name
length check on name
[2]

You might also like