AQA 7517 1 Final MS Jun24 v1.0
AQA 7517 1 Final MS Jun24 v1.0
COMPUTER SCIENCE
7517/1
Paper 1
Mark scheme
June 2024
Version: 1.0 Final
*246A7517/1/MS*
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Mark schemes are prepared by the Lead Assessment Writer and considered, together with the relevant
questions, by a panel of subject teachers. This mark scheme includes any amendments made at the
standardisation events which all associates participate in and is the scheme which was used by them in
this examination. The standardisation process ensures that the mark scheme covers the students’
responses to questions and that every associate understands and applies it in the same correct way. As
preparation for standardisation each associate analyses a number of students’ scripts. Alternative
answers not already covered by the mark scheme are discussed and legislated for. If, after the
standardisation process, associates encounter unusual answers which have not been raised they are
required to refer these to the Lead Examiner.
It must be stressed that a mark scheme is a working document, in many cases further developed and
expanded on the basis of students’ reactions to a particular paper. Assumptions about future mark
schemes on the basis of one year’s document should be avoided; whilst the guiding principles of
assessment remain constant, details will change, depending on the content of a particular examination
paper.
No student should be disadvantaged on the basis of their gender identity and/or how they refer to the
gender identity of others in their exam responses.
A consistent use of ‘they/them’ as a singular and pronouns beyond ‘she/her’ or ‘he/him’ will be credited in
exam responses in line with existing mark scheme criteria.
Copyright information
AQA retains the copyright on all its publications. However, registered schools/colleges for AQA are permitted to copy material from this booklet for their own
internal use, with the following important exception: AQA cannot give permission to schools/colleges to photocopy any material that is acknowledged to a third
party even for internal use within the centre.
2
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Before you apply the mark scheme to a student’s answer read through the answer and annotate it (as
instructed) to show the qualities that are being looked for. You can then apply the mark scheme.
When assigning a level you should look at the overall quality of the answer and not look to pick holes in
small and specific parts of the answer where the student has not performed quite as well as the rest. If
the answer covers different aspects of different levels of the mark scheme you should use a best fit
approach for defining the level and then use the variability of the response to help decide the mark within
the level, ie if the response is predominantly level 3 with a small amount of level 4 material it would be
placed in level 3 but be awarded a mark near the top of the level because of the level 4 content.
You may well need to read back through the answer as you apply the mark scheme to clarify points and
assure yourself that the level and the mark are appropriate.
Indicative content in the mark scheme is provided as a guide for examiners. It is not intended to be
exhaustive and you must credit other valid points. Students do not have to cover all of the points
mentioned in the Indicative content to reach the highest level of the mark scheme.
An answer which contains nothing of relevance to the question must be awarded no marks.
3
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
June 2024
4
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Examiners are required to assign each of the candidate’s responses to the most appropriate level
according to its overall quality, and then allocate a single mark within the level. When deciding upon a
mark in a level, examiners should bear in mind the relative weightings of the assessment objectives
eg
In question 07.1, the marks available for the AO3 elements are as follows:
Where a candidate’s answer only reflects one element of the AO, the maximum mark they can receive
will be restricted accordingly.
5
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
01 All marks AO1 (understanding) 3
Example answers
Max 3
Mark should only be awarded if the explanation is relevant for the stated
advantaged.
6
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
02 1 All marks AO1 (understanding) 2
When an item is removed from a linear queue; A. by implication that problem arises
when items have been deleted
all other items need to be shuffled up one // this can result in unusable space in
the array // this can result in only being able to add a limited number of items to the
queue (eg only ever being able to add five items to a queue which uses an array of
size 5);
Alternative answer
1. Check that the queue is not already empty // check to see if the current size is 0;
R. reference to array instead of queue
2. if it is then deal with (underflow) error // (If it is not then) process/dequeue the
front item in the queue; R. reference to array instead of queue (unless reference
to array is made using value of front pointer) R. if dequeue would only happen
under some of the correct circumstances
3. Reduce the value of the variable used to store the current size by 1;
4. Check if the front is in the last position of the array and if it is set it to the first
position in the array (A. 0 or 1 instead of first position in the array);
Alternative to mark points 4 and 5: add 1 to the value of the front pointer; then
set it to the remainder from dividing the value of front by the maximum size of the
queue;
Alternative to mark points 4 and 5: add 1 to the value of the front pointer; then if
the pointer has passed the end of the array set it to point to the start of the array.
7
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
03 1 All marks AO1 (knowledge) 2
Max 1 for the following points, but only award mark if 1st mark was awarded:
8
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
04 1 Mark is for AO1 (knowledge) 1
1 // one;
or //
alternation;
a(bb)*|(bb)+
Mark as follows:
Alternative answer
a|a?(bb)+
Mark as follows:
9
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Alternative answer
(a|bb)(bb)*
Mark as follows:
(ab|b)(bb)*
Mark as follows:
Alternative answer
a?b(bb)*
Mark as follows:
10
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
05 1 Mark is for AO1 (understanding) 1
523*+4+;;
Mark as follows:
11
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
06 1 All marks AO1 (understanding) 2
Connected;
Undirected;
A. explanations of connected/undirected
Temp
Done Pos [0] [1] [2] Current OUTPUT
False -1 0
0 0 1
1 1 2
2 2 -1 Y
-1
1 K
3
0
1 3 -1 H
-1
0 U
4
-1
0 4 -1 M
-1
-1
True
Mark as follows:
12
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Note for examiners: if answer is not correct then max one mark for any of the
following points:
• each node has, at most, one child node R. each node has one child node
• there are no nodes with two child nodes
• tree has a depth of five
//
13
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
07 1 4 marks for AO3 (design) and 8 marks for AO3 (programming) 12
Mark Scheme
14
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Guidance
Note that AO3 (design) points are for selecting appropriate techniques to use to
solve the problem, so should be credited whether the syntax of programming
language statements is correct or not and regardless of whether the solution works.
15
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Screen captures showing the integer(s) entered and result(s) of each of the tests;
I. order of tests
Note for examiners: example screen captures shown here match the order of the
test data given in the question but there is no requirement for the tests to be done in
any particular order.
16
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
08 1 Mark is for AO1 (knowledge) 1
One // 1;
Zero // 0;
Question Marks
09 1 Mark is for AO2 (apply) 1
17
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
10 1 Mark is for AO2 (analyse) 1
LoadPuzzle //
AttemptPuzzle;
I. case
A. __LoadPuzzle (Python only)
A. __AttemptPuzzle (Python only)
R. if any other code included
It would not match with some valid patterns (if the iteration structures were not
outside the exception handling structure)
//
it would not find patterns that start in the first/top two rows of the grid (if the iteration
structures were not outside the exception handling code)
//
it would stop looking for patterns as soon as a location outside of the bounds of the
array was checked (if the iteration structures were not outside the exception
handling structure);
To prevent the program crashing / terminating; when a cell outside the grid/list is
checked; because it would be within a 3x3 grid with the cell the user has just
entered a symbol in // because the user has just entered a symbol in a cell near the
top or bottom of the grid;
//
To simplify the code structure; by avoiding the need to use many if
statements/conditions; to avoid checking cells that are outside the grid/list;
The grid is stored in a one-dimensional list // the top-left symbol of the 3x3 pattern is
in the last two columns of the grid;
18
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
11 1 All marks for AO3 (programming) 4
Alternative answer
19
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
12 1 All marks for AO3 (programming) 5
1. Create variables for average/total and highest, set to appropriate start values //
creates a list to store all the scores for completed puzzles;
R. if not in appropriate location
A. equivalent variables
2. Compare final score for puzzle to highest score so far;
3. Change highest score found so far if condition for selection structure is met;
A. incorrect condition
4. Calculate new average; A. calculate new total as long as there is an attempt to
calculate average later in the code.
5. Display average and highest scores after iteration structure that checks if the user
wants to do another puzzle; A. inside iterative stucture if also inside a selection
structure that checks that the user does not want to do another puzzle
20
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
21
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Screen capture(s) showing puzzle1 was used followed by correct high score and
average score;
22
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
13 1 All marks for AO3 (programming) 11
Max 2 marks for mark points 2, 4, 6 if actual numeric value used instead of
GridSize
Max 1 mark for mark points 5, 6 if any cell would be lost during the shifting process
23
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Screen capture(s) showing the correct final grid state and score for the user;
(–1, 0);
(GridSize - 1, 0);
24
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Question Marks
14 1 All marks for AO3 (programming) 13
25
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
26
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Note for examiners: the location of the cell that shows a 3 (then 2, then 1, then @)
and the three cells containing Ts (apart from row 1, column 5) are likely to be
different to those shown here.
27
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
VB.Net
Question Marks
07 1 Console.Write("Enter a number: ") 12
Dim n As Integer = Console.ReadLine()
While n <= 0
Console.Write("Enter a number: ")
n = Console.ReadLine()
End While
Dim Decreasing As Boolean = True
Dim Increasing As Boolean = True
Dim NoOfDecreasing As Integer = 0
Dim NoOfIncreasing As Integer = 0
Dim NumberAsString As String = n.ToString()
For Count = 0 To NumberAsString.Length - 2
If NumberAsString(Count) < NumberAsString(Count + 1) Then
Decreasing = False
NoOfIncreasing += 1
ElseIf NumberAsString(Count) > NumberAsString(Count + 1) Then
Increasing = False
NoOfDecreasing += 1
End If
Next
If Not Decreasing And Not Increasing Then
If NoOfDecreasing = NoOfIncreasing Then
Console.WriteLine("perfectly bouncy")
Else
Console.WriteLine("bouncy")
End If
Else
Console.WriteLine("not bouncy")
End If
28
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
12 1 Sub Main() 5
Dim Again As String = "y"
Dim Score As Integer
Dim HighScore As Integer = 0
Dim AverageScore As Single = 0
Dim NumberOfPuzzles As Integer = 0
While Again = "y"
Console.Write("Press Enter to start a standard puzzle or enter
name of file to load: ")
Dim Filename As String = Console.ReadLine()
Dim MyPuzzle As Puzzle
If Filename.Length > 0 Then
MyPuzzle = New Puzzle(Filename & ".txt")
Else
MyPuzzle = New Puzzle(8, Int(8 * 8 * 0.6))
End If
Score = MyPuzzle.AttemptPuzzle()
If Score > HighScore Then
HighScore = Score
End If
AverageScore = AverageScore * NumberOfPuzzles + Score
NumberOfPuzzles = NumberOfPuzzles + 1
AverageScore = AverageScore / NumberOfPuzzles
Console.WriteLine("Puzzle finished. Your score was: " & Score)
Console.WriteLine("Do another puzzle? ")
Again = Console.ReadLine().ToLower()
End While
Console.WriteLine("High score: " & HighScore)
Console.WriteLine("Average score: " & AverageScore)
Console.ReadLine()
End Sub
29
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
30
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
14 1 Class CountdownCell 13
Inherits BlockedCell
Sub New()
Timer = 4
Symbol = Timer
End Sub
31
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Python 3
Question Marks
07 1 n = int(input("Enter a number: ")) 12
while n <= 0:
n = int(input("Enter a number: "))
Decreasing = True
NoOfDecreasing = 0
NoOfIncreasing = 0
Increasing = True
n = str(n)
for count in range(len(n) - 1):
if n[count] < n[count + 1]:
Decreasing = False
NoOfIncreasing += 1
elif n[count] > n[count + 1]:
Increasing = False
NoOfDecreasing += 1
if not Decreasing and not Increasing:
if NoOfDecreasing == NoOfIncreasing:
print("perfectly bouncy")
else:
print("bouncy")
else:
print("not bouncy")
11 1 def AttemptPuzzle(self): 4
Finished = False
while not Finished:
...
while not Valid:
...
Valid = False
while not Valid:
try:
Column = int(input("Enter column number: "))
Valid = True
if Column < 1 or Column > self.__GridSize:
Valid = False
except:
pass
Symbol = self.__GetSymbolFromUser()
32
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
12 1 def Main(): 5
Again = "y"
Score = 0
HighScore = 0
AverageScore = 0
NumberOfPuzzles = 0
while Again == "y":
FileName = input("Press Enter to start a standard puzzle or
enter name of file to load: ")
if len(FileName) > 0:
MyPuzzle = Puzzle(FileName + ".txt")
else:
MyPuzzle = Puzzle(8, int(8 * 8 * 0.6))
Score = MyPuzzle.AttemptPuzzle()
if Score > HighScore:
HighScore = Score
AverageScore = AverageScore * NumberOfPuzzles + Score
NumberOfPuzzles += 1
AverageScore = AverageScore / NumberOfPuzzles
print("Puzzle finished. Your score was: " + str(Score))
Again = input("Do another puzzle? ").lower()
print("High score: " + str(HighScore))
print("Average score: " + str(AverageScore))
def AttemptPuzzle(self):
Finished = False
while not Finished:
...
while not Valid:
try:
Row = int(input("Enter row number or 0 to shift: "))
Valid = True
except:
pass
if Row == 0:
RowToShift = int(input("Enter row number to shift: "))
self.__ShiftCellsInRowLeft(RowToShift)
self.__Score = self.__Score - 20
self.DisplayPuzzle()
print("Current score:", self.__Score)
Valid = False
Valid = False
while not Valid:
...
33
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
14 1 class CountdownCell(BlockedCell): 13
def __init__(self):
super(CountdownCell, self).__init__()
self.__Timer = 4
self._Symbol = str(self.__Timer)
def UpdateCell(self):
self.__Timer -= 1
if self.__Timer <= 0:
self._Symbol = "@"
else:
self._Symbol = str(self.__Timer)
def AttemptPuzzle(self):
...
if AmountToAddToScore > 0:
self.__Score += AmountToAddToScore
GridPosition = -1
while GridPosition == -1:
GridPosition = random.randrange(0, len(self.__Grid))
if self.__Grid[GridPosition].GetSymbol() != "-":
GridPosition = -1
self.__Grid[GridPosition] = CountdownCell()
for c in self.__Grid:
c.UpdateCell()
if self.__SymbolsLeft == 0:
Finished = True
34
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Python 2
Question Marks
07 1 n = int(raw_input("Enter a number: ")) 12
while n <= 0:
n = int(raw_input("Enter a number: "))
Decreasing = True
NoOfDecreasing = 0
NoOfIncreasing = 0
Increasing = True
n = str(n)
for count in range(len(n) - 1):
if n[count] < n[count + 1]:
Decreasing = False
NoOfIncreasing += 1
elif n[count] > n[count + 1]:
Increasing = False
NoOfDecreasing += 1
if not Decreasing and not Increasing:
if NoOfDecreasing == NoOfIncreasing:
print "perfectly bouncy"
else:
print "bouncy"
else:
print "not bouncy"
11 1 def AttemptPuzzle(self): 4
Finished = False
while not Finished:
...
while not Valid:
...
Valid = False
while not Valid:
try:
Column = int(raw_input(“Enter column number: “))
Valid = True
if Column < 1 or Column > self.__GridSize:
Valid = False
except:
pass
Symbol = self.__GetSymbolFromUser()
35
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
12 1 def Main(): 5
Again = “y”
Score = 0
HighScore = 0
AverageScore = 0
NumberOfPuzzles = 0
while Again == “y”:
FileName = raw_input("Press Enter to start a standard puzzle or
enter name of file to load: ")
if len(FileName) > 0:
MyPuzzle = Puzzle(FileName + ".txt")
else:
MyPuzzle = Puzzle(8, int(8 * 8 * 0.6))
Score = MyPuzzle.AttemptPuzzle()
if Score > HighScore:
HighScore = Score
AverageScore = AverageScore * NumberOfPuzzles + Score
NumberOfPuzzles += 1
AverageScore = AverageScore / NumberOfPuzzles
Print "Puzzle finished. Your score was: " + str(Score)
Again = raw_input("Do another puzzle? ").lower()
Print "High score: " + str(HighScore)
Print "Average score: " + str(AverageScore)
def AttemptPuzzle(self):
Finished = False
while not Finished:
...
while not Valid:
try:
Row = int(raw_input("Enter row number or 0 to shift: "))
Valid = True
except:
pass
if Row == 0:
RowToShift = int(raw_input("Enter row number to shift: "))
self.__ShiftCellsInRowLeft(RowToShift)
self.__Score = self.__Score - 20
self.DisplayPuzzle()
print "Current score: " + str(self.__Score)
Valid = False
Valid = False
while not Valid:
...
36
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
14 1 class CountdownCell(BlockedCell): 13
def __init__(self):
super(CountdownCell, self).__init__()
self.__Timer = 4
self._Symbol = str(self.__Timer)
def UpdateCell(self):
self.__Timer -= 1
if self.__Timer <= 0:
self._Symbol = "@"
else:
self._Symbol = str(self.__Timer)
def AttemptPuzzle(self):
...
if AmountToAddToScore > 0:
self.__Score += AmountToAddToScore
GridPosition = -1
while GridPosition == -1:
GridPosition = random.randrange(0, len(self.__Grid))
if self.__Grid[GridPosition].GetSymbol() != "-":
GridPosition = -1
self.__Grid[GridPosition] = CountdownCell()
for c in self.__Grid:
c.UpdateCell()
if self.__SymbolsLeft == 0:
Finished = True
37
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
C#
Question Marks
07 1 int n; 12
do
{
Console.WriteLine("Enter a number");
n = Convert.ToInt32(Console.ReadLine());
38
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
39
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
40
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
41
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
public CountdownCell()
{
Timer = 4;
Symbol = Timer.ToString();
}
42
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Pascal/Delphi
Question Marks
07 1 program Q07; 12
{$APPTYPE CONSOLE}
Uses SysUtils;
var
n: integer;
digits: string;
increases, decreases: integer;
i: integer;
begin
repeat
write('Enter a number: ');
readln(n);
until n > 0;
digits := IntToStr(n);
increases := 0;
decreases := 0;
for i := 2 to digits.Length do
begin
if digits[i] >= digits[i - 1] then
begin
inc(increases);
end;
if digits[i] <= digits[i - 1] then
begin
inc(decreases);
end;
end;
if (increases <> digits.Length - 1) and (decreases <>
digits.Length - 1) then
begin
if increases = decreases then
begin
writeln(digits + ' is perfectly bouncy');
end
else
begin
writeln(digits + ' is bouncy');
end;
end
else
begin
writeln(digits + ' is not bouncy');
end;
readln;
end.
43
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
12 1 procedure Main(); 5
var
Again: string;
Score: integer;
Filename: string;
MyPuzzle: Puzzle;
HighestScore, TotalScore, PuzzlesAttempted: integer;
begin
Randomize();
Again := 'y';
HighestScore := -1;
TotalScore := 0;
PuzzlesAttempted := 0;
while Again = 'y' do
begin
write('Press Enter to start a standard puzzle or enter name of
file to load: ');
readln(Filename);
if Filename.Length > 0 then
begin
MyPuzzle := Puzzle.Create(Filename + '.txt');
end
else
begin
MyPuzzle := Puzzle.Create(8, Trunc(8 * 8 * 0.6));
end;
Score := MyPuzzle.AttemptPuzzle();
inc(PuzzlesAttempted);
if Score > HighestScore then
begin
HighestScore := Score;
end;
inc(TotalScore, Score);
writeln('Puzzle finished. Your score was ' + IntToStr(Score));
write('Do another puzzle? ');
readln(Again);
Again := LowerCase(Again);
end;
writeln('Highest score: ', HighestScore, ', average score:
', TotalScore / PuzzlesAttempted:3:1);
readln;
end;
44
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
13 1 Puzzle = class 11
private
Score: integer;
SymbolsLeft: integer;
GridSize: integer;
Grid: TList<Cell>;
AllowedPatterns: TList<Pattern>;
AllowedSymbols: TList<string>;
procedure LoadPuzzle(FileName: string);
function GetCell(Row: integer; Column: integer): integer;
function CheckForMatchWithPattern(Row: integer; Column:
integer): integer; virtual;
function GetSymbolFromUser(): string;
function CreateHorizontalLine(): string;
procedure ShiftCellsInRowLeft(Row: integer);
public
constructor Create(Filename: string); overload;
constructor Create(Size: integer; StartSymbols: integer);
overload;
function AttemptPuzzle(): integer; virtual;
procedure DisplayPuzzle(); virtual;
end;
45
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
14 1 CountdownCell = Class(BlockedCell) 13
private
Timer: integer;
public
constructor Create();
function GetSymbol(): string; override;
procedure UpdateCell(); override;
end;
constructor CountdownCell.Create();
begin
Timer := 4;
end;
procedure CountdownCell.UpdateCell();
begin
if Timer > 0 then
begin
dec(Timer);
end;
end;
procedure AddCountdownCell();
var
i: integer;
begin
repeat
i := random(Grid.Count);
until Grid[i].IsEmpty();
Grid[i] := CountdownCell.Create();
end;
46
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
inc(Score, AmountToAddToScore);
end;
end;
for c in Grid do
begin
c.UpdateCell();
end;
if SymbolsLeft = 0 then
begin
Finished := true;
end;
end;
...
47
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
Java
Question Marks
07 1 int number = 0; 12
while (number <= 0) {
Console.write("Enter a number: ");
number = Integer.parseInt(Console.readLine());
}
boolean increasing = true;
boolean decreasing = true;
int noDecreasing = 0;
int noIncreasing = 0;
String numberStr = Integer.toString(number);
for (int i = 0; i < numberStr.length() - 1; i++) {
if (numberStr.charAt(i) < numberStr.charAt(i + 1)) {
decreasing = false;
noIncreasing++;
} else if (numberStr.charAt(i) > numberStr.charAt(i + 1)) {
increasing = false;
noDecreasing++;
}
}
if (!decreasing && !increasing) {
if (noIncreasing == noDecreasing) {
Console.writeLine("perfectly bouncy");
} else {
Console.writeLine("bouncy");
}
} else {
Console.writeLine("not bouncy");
}
48
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
49
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
50
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2024
public CountdownCell() {
timer = 4;
symbol = "4";
}
@Override
public void updateCell() {
timer -= 1;
if (timer <= 0) {
symbol = "@";
} else {
symbol = Integer.toString(timer);
}
}
}
51