CSC-9618 Mock 1 Paper 2 (MS)
CSC-9618 Mock 1 Paper 2 (MS)
Name: Sequence
Description: Instructions / lines of code are executed in a fixed order
OR
Name: Assignment
Description: A value is given to a variable
Max 3
Question Answer Marks
Max 2
Note:
Must include reference to given scenario to achieve all 3 marks - Max 2 if no
reference.
Question Answer Marks
2(b)(ii) 6
Notes:
Parameter types must be as shown but ignore parameter names (if given)
Question Answer Marks
Check INT(Deviate(Course))
Adjust 255
CASE OF Check
-20 to -1: Adjust 10
0 : Adjust 0
1 to 20 : Adjust -10
OTHERWISE CALL Alert()
ENDCASE
RETURN Adjust
ENDFUNCTION
REPEAT
Rnum INT(RAND(100)) + 1 // from original question
Exists FALSE
FOR Index 1 to NextNum - 1 // search for Rnum
IF Random[Index] = Rnum
THEN
Exists TRUE
ENDIF
ENDFOR
IF Exists = FALSE
THEN
Random[NextNum] Rnum // store Rnum
NextNum NextNum + 1 // increment index
ENDIF
UNTIL NextNum > 10
Notes:
Max 5 if statement to generate random number (as given in Q) not present or
incorrectly placed.
Alternative Solution:
Mark as follows:
1 SET Index to 1
2 SELECT the character from input parameter string at Index position
3 IF character is colon then go to 5
4 Else INCREMENT Index and repeat from 2
5 Extract a substring from the left of the parameter string (and assign this to
variable Name)
6 ...Using Index -1 for the length
7 RETURN Name
Note:
Mark points may be combined for equivalent marks
e.g a suitable structured English description of the pseudocode statement
below satisfies MP 5, 6 and 7:
5(b)(i) Description: 4
5(b)(ii) 'Pseudocode' solution included here for development and clarification of mark 8
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE BubbleSort()
DECLARE Temp : STRING
DECLARE NoSwaps : BOOLEAN
DECLARE Boundary, J : INTEGER
Boundary 999
REPEAT
NoSwaps TRUE
FOR J 1 TO Boundary
IF Contact[J] > Contact[J+1]
THEN
Temp Contact[J]
Contact[J] Contact[J+1]
Contact[J+1] Temp
NoSwaps FALSE
ENDIF
ENDFOR
Boundary Boundary - 1
UNTIL NoSwaps = TRUE
ENDPROCEDURE
Mark as follows:
StartHours STRING_TO_NUM(LEFT(StartTime,2))
StartMinutes STRING_TO_NUM(RIGHT(StartTime, 2))
Total (StartHours * 60) + StartMinutes + Duration
NewHours DIV(Total, 60)
NewMinutes MOD(Total, 60)
NewTime ""
IF NewHours < 10
THEN
NewTime '0' // add leading zero to hours
ENDIF
IF NewMinutes < 10
THEN
NewTime NewTime & '0'// add leading zero
ENDIF
RETURN NewTime
ENDFUNCTION
Note:
Accept alternative methods for calculation of NewHours and NewMinutes
Explanation:
Suitable explanation
Note:
Accept times that would also be invalid for the given scenario.
6(c) 'Pseudocode' solution included here for development and clarification of mark 8
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE GetTotals()
ENDWHILE
CLOSEFILE "Hirelog.txt"
ENDPROCEDURE
Sub BubbleSort()
Dim Temp As String
Dim NoSwaps As Boolean
Dim Boundary, J As Integer
Boundary = 999
Do
NoSwaps = TRUE
For J = 1 To Boundary
If Contact(J) > Contact(J+1) Then
Temp = Contact(J)
Contact(J) = Contact(J+1)
Contact(J+1) = Temp
NoSwaps = FALSE
End If
Next
Boundary = Boundary - 1
Loop Until NoSwaps = TRUE
End Sub
Q5(b)(i): Pascal
procuedre BubbleSort()
var
Temp : String;
NoSwaps : Boolean;
Boundary, J : Integer;
Boundary := 999
repeat
begin
NoSwaps := TRUE
for J := 1 to Boundary do
begin
if Contact[J] > Contact[J+1]then
begin
Temp := Contact[J];
Contact[J] := Contact[J+1];
Contact[J+1] := Temp;
NoSwaps := FALSE;
end;
end;
Boundary := Boundary – 1
end;
until NoSwaps = TRUE;
End Sub
Q5(b)(i): Python
def BubbleSort()
# Temp : String
# NoSwaps : Boolean
# Boundary, J : Integer
Boundary = 999
NoSwaps = TRUE
Boundary = Boundary - 1
End Sub
Sub GetTotals()
For BoatNum = 1 To 17
Total(BoatNum) = 0
Next
File.Close()
End Sub
Q6(c): Pascal
procedure GetTotals()
var
BoatNum : Integer;
Paid : Real;
MyFile : testfile;
for BoatNum := 1 to 17 do
Total[BoatNum] := 0;
assignFile(MyFile, "Hirelog.txt");
reset(MyFile);
close(MyFile)
end;
def GetTotals()
# BoatNum : Integer
# Paid : Real
# File : File Handle
# FileData : String
File.Close()