Paper 2 Final Mock Ms
Paper 2 Final Mock Ms
(a) Write a pseudocode routine that sets each element to zero. Use the most suitable loop
structure.....................................................................................................................................
............................................................................................................................................. [3]
...................................................................................................................................................
............................................................................................................................................. [1]
2. count the number of strings in the array that exactly match the search string
3. return TRUE if the count is greater than the maximum value, otherwise will return FALSE
1
............................................................................................................................................. [6]
(b) The global array is changed to a 2D array, organised as 150 rows by 2 columns. It is
declared
in pseudocode as follows:
DECLARE Data : ARRAY[1:150, 1:2] OF STRING
The algorithm for the function in part (a) is changed. Strings will only be counted if both of
the following conditions are true:
• The current row is an even number.
• The search string exactly matches the value in either column.
Write pseudocode to check these conditions.
Assume that the row index is contained in variable Row and the search string in variable
Search............................................................................................................................................
2
.....................................................................................................................................................
[3]
A function, ProcessMarks(), is required to analyse test marks for a class of students.
• There are 20 students in the class.
• A mark is between 0 and 100.
• The marks for the class are stored in an array, Mark, which has 20 elements.
• The array is passed to the function as a parameter.
• The function will output a message stating the average and highest marks. For example:
"The average mark is 34 and the highest mark is 76"
• The function returns the subscript of the highest mark.
Write program code to implement the ProcessMarks() function. [7]
3
4
5
6
20. A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first name, last
name, their year 10 test score and their year 11 test score. The class has 32 students.
(a) State the number of fields and records required for this database.
Number of Fields ......................................................................................................................
Number of Records .................................................................................................................. [2]
7
(b) The data in MARKBOOK is stored under category headings: LastName, FirstName, Y10TestScore
and Y11TestScore. State, with a reason, whether any of these headings would be suitable as a
primary key.
...........................................................................................................................................................
...................................................................................................................................................... [2]
(c) Write the SQL code to only display the first name, last name and year 10 test score of each
student who achieved 50 or more in their year 10 test. The output should be in test score order
with the highest marks at the top of the list.
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
…………………………………………………………………………………………………..[4]
2210/21/M/J/23
10 The variables X, Y and Z are used in a program: X stores a whole number, Y stores a
decimal number and Z stores a flag that can be set to TRUE or FALSE
(a) Write pseudocode statements to declare the variables X, Y and Z
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) The function Same(A,B) returns TRUE if the value of A is the same as the value of B
8
when B
is rounded to the nearest whole number and FALSE otherwise.
Write pseudocode statements to:
• define the function
• call the function with X and Y and store the return value in Z
Function definition ....................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Function call .............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..............................................................................................................................................[6]
9
10
11
4 A procedure Count() will: [15]
i. input values (all values will be positive integers) into the 2D array Values[] of 50 rows and 50
columns.
ii. count the number of odd values and count the number of even values. Store the values in the 2
1D arrays Odd[] and Even[]
iii. repeat from step 1 until the value input is 99
iv. find the average of the odd numbers and the average of the even numbers (Rounded to next
whole number. E.g. 4.1 will be rounded to 5)
v. output the two count values, with a suitable message.
vi. store the averages in the file “Averages.txt” with a suitable message
vii. The value 99 must not be counted.
Write pseudocode for the procedure Count().
12