[go: up one dir, main page]

0% found this document useful (0 votes)
21 views6 pages

Paper 2

This document outlines a Computer Science examination paper focused on the application of computational thinking, with a total of 80 marks. It includes questions on coding, logical errors, variable types, sorting algorithms, and data handling for employee salary calculations. The paper requires students to write and amend code based on provided scenarios and pseudocode.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

Paper 2

This document outlines a Computer Science examination paper focused on the application of computational thinking, with a total of 80 marks. It includes questions on coding, logical errors, variable types, sorting algorithms, and data handling for employee salary calculations. The paper requires students to write and amend code based on provided scenarios and pseudocode.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer Science

PAPER 2: Application of Computational Thinking


The total mark for this paper is 80.

Name: ................................................
1(a)Open Q01a in the code editor. Use the code to answer these questions.
(i) Give the text of a comment used in the code.

(1)
(ii) Give the text of a line that creates and initialises a variable.

(1)
(iii) Give the keyword that starts the selection used in the code.

(1)
(iv) Give a relational operator used in the code.

(1)
(v) Give a logical operator used in the code.

(1)
(b) Programs can have Logical errors.
(i) State what is meant by the term Logical error.

(2)
(ii) Give one example of a Logical error.

(1)

(c) Programmers write code and use subprograms. Global variables are different from local variables.
(i) State where a global variable is created and its use

(1)
(ii) State where a local variable is accessible and its use

(1)
2 (a) Below shows the Sales.txt file. It stores sales information.

Smith,264,140,120,284,192
Anne,420,377,435,376,392
Charlete,619,589,606,586,600
William,799,811,788,814,788
Robin,982,1007,1013,989,1009

A program is required to calculate and display:


 a subtotal for each line of sales
 a grand total for all the sales in the file.
 name of the best seller (person who made most sales)

Below shows the intended output from the program.


1000
2000
3000
4000
5000
Grand total : 15000
Best Seller : Robin

Open Q02a in the code editor. Amend the code to produce the intended output. Do not add any further
functionality.
Save your code as Q02aFINISHED with the correct file extension for the programming language. (10)

(b) A merge sort algorithm can be used to sort a list into ascending order.
The list 4, 1, 7, 9, 3, 5, 2, 6 needs to be sorted.
Complete the merge sort using the space provided.

4, 1, 7, 9, 3, 5, 2, 6

1, 2, 3, 4, 5, 6, 7, 9 (5)
3 (a) Complete the table by giving an example value for each data type.

The first row has been completed for you.

Data type Example value

integer 12
char
real
Boolean
Float
String

(5)

(b) A program is required to calculate and display the result (name and average marks) for five students. The
flowchart for the algorithm is given below.

Open Q03b in the code editor. Write a program to implement the logic in the flowchart. Do not add any further
functionality. Save your code as Q03bFINISHED with the correct file extension for the programming language.
(10)
4 (a) Car registration codes consist of seven characters. The characters are ;

 Two upper case letters from the registered province followed by


 Two numbers which are the first two digits of the manufactured year and then
 Three upper case letters which are the last three letters from the registerd district name.
 The program must ensure the code is only seven characters long
 WE22HRA, SO20MBO are valid codes.

Open Q04a in the code editor. Amend the code to construct a new code.
Do not add any further functionality.
Save your code as Q04cFINISHED with the correct file extension for the programming language.
[6]

(b) Below is an array that stores student marks after an examination.

45 69 88 74 35 25

Tim uses a bubble sort algorithm to sort the marks. Complete the table to show how the bubble sort algorithm
will sort the marks. You may not need to use all the rows.

45 69 88 74 35 25

(4)
5 Anne is learning about sorting and searching algorithms.
(a) Anne’s friend has given her a partially completed program to carry out a binary search.
This pseudocode contains the logic required to complete the program.

SET numberList TO [2,5,7,8,69,85,95,99]


SET start TO 0
SET end TO LENGH(numberList)-1
SET Found TO FALSE
RECEIVE item FROM (INTEGER) KEYBOARD
WHILE start <= end AND NOT found DO
SET middle TO (start + end) DIV 2
IF numberList[middle] = item THEN
SET found TO TRUE
ELSE
IF item < numberList[middle] THEN
end = middle – 1
ELSE
start = middle + 1
END IF
END IF
END WHILE

Open Q05a in the code editor. Write a program to implement the logic in the pseudocode. Do not add any
further functionality. Save your code as Q05aFINISHED with the correct file extension for the programming
language. (6)

(b) Complete the trace table below with the input Item = 5

Start End Found Item Middle

(4)
6 A financial company has several employees. Data collected for the employees is stored in arrays. The data
stored is:

 the employee number (four-character string)


 the name of the employee
 the contact number of the employee (ten-character string)
 the department code (4-character string)
 the basic salary of the employee (six-digit real value)
 the other allowances being paid (six-digit real value)

The company wants to present the data to the director board to make year-end decisions about its staff.
Open the file Q06 in the code editor.

Write a program to:

 calculate and display the total salary/money earned by each employee


 add this salary and the employee number to the data structure SalaryDetails
 calculate and display the total salary/money paid to all employees
 calculate and display the average salary paid to an employee in the company
 find and display the employee names and departments for the first three highly paid employees in
descending order (first, second and third. Ignore the possibility of two or more members of the staff
having the same salary.)
 find and increase the basic salary by 5% for all employees ho have a basic salary that is below the
average salary of the company (Employee_Data structure must be updated) (20)

You might also like