Marking Scheme Paper 4 M.T
Marking Scheme Paper 4 M.T
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the May/June 2023 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.
These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptors for a question. Each question paper and mark scheme will also comply with these
marking principles.
the specific content of the mark scheme or the generic level descriptors for the question
the specific skills defined in the mark scheme or in the generic level descriptors for the question
the standard of response required by a candidate as exemplified by the standardisation scripts.
Marks awarded are always whole marks (not half marks, or other fractions).
marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
marks are awarded when candidates clearly demonstrate what they know and can do
marks are not deducted for errors
marks are not deducted for omissions
answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.
Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.
Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.
Java
public static Integer[] DataArray = new Integer[25];
VB.NET
Python
DataArray = [] #25 elements Integer
Java
Integer Counter = 0;
try{
Scanner Scanner1 = new Scanner(new File("Data.txt"));
while(Scanner1.hasNextLine()){
DataArray[Counter] = Integer.parseInt(Scanner1.next());
Counter++;
}
Scanner1.close();
}catch(FileNotFoundException ex){
System.out.println("No data file found");
}
VB.NET
try
Dim DataReader As New System.IO.StreamReader("Data.txt")
Dim X As Integer = 0
Do Until DataReader.EndOfStream
DataArray(X) = DataReader.ReadLine()
X = X + 1
Loop
DataReader.Close()
Catch ex As Exception
Console.WriteLine("Invalid file")
End Try
1(a)(ii) Python
try:
DataFile = open("Data.txt",'r')
for Line in DataFile:
DataArray.append(int(Line))
DataFile.close()
except IOError:
print("Could not find file")
Java
public static void PrintArray(Integer[] DataArray){
String OutputData;
for(Integer X = 0; X < DataArray.length - 1; X++){
OutputData = OutputData + DataArray[X] + " ";
}
System.out.print(OutputData);
}
VB.NET
Sub PrintArray(DataArray)
Dim OutputData As String = "";
For x = 0 To DataArray.length - 1
OutputData = OutputData & DataArray(x) & " "
Next
Console.WriteLine(OutputData)
End Sub
Python
def PrintArray(DataArray):
output = ""
for X in range(0, len(DataArray)):
output = output + str((DataArray[X])) + " "
print(output)
Java
PrintArray(DataArray);
VB.NET
PrintArray(DataArray)
Python
PrintArray(DataArray)
e.g.
Java
public static Integer LinearSearch(Integer[] DataArray, Integer DataToFind){
Integer Count = 0;
for(Integer x = 0; x < DataArray.length - 1; x++){
if(DataArray[x] == DataToFind){
Count++;
}
}
return Count;
}
VB.NET
Function LinearSearch(DataArray, DataToFind)
Dim Count As Integer = 0
For x = 0 To DataArray.length - 1
If DataArray(x) = DataToFind Then
Count = Count + 1
End If
Next
Return Count
End Function
Python
def LinearSearch(DataArray, DataToFind):
Count = 0
for X in range(0, len(DataArray)):
if(DataArray[X] == DataToFind):
Count +=1
return Count
Java
System.out.println("Enter a number to find");
Integer DataToFind = -1;
Scanner NewScanner = new Scanner(System.in);
while(DataToFind < 0 || DataToFind > 100){
DataToFind = Integer.parseInt(NewScanner.nextLine());
}
Integer NumberTimes = LinearSearch(DataArray, DataToFind);
System.out.println("The number " + DataToFind + " is found " + NumberTimes + " times");
VB.NET
Console.WriteLine("Enter a number to find ")
Dim DataToFind As Integer = -1
Do Until DataToFind >= 0 And DataToFind <= 100
DataToFind = Console.ReadLine()
Loop
Dim NumberTimes = LinearSearch(DataArray, DataToFind)
Console.WriteLine("The number " & DataToFind & " is found " & NumberTimes & " times.")
Python
DataToFind = int(input("Enter a number to find "))
while DataToFind < 0 or DataToFind > 100:
DataToFind = int(input("Enter a number to find "))
NumberTimes = LinearSearch(DataArray, DataToFind)
print("The number", DataToFind, "is found", NumberTimes, "times")
public Tree(String Name, Integer HGrowth, Integer MaxH, Integer MaxW, String
PEvergreen){
TreeName = Name;
HeightGrowth = HGrowth;
MaxWidth = MaxW;
MaxHeight = MaxH;
Evergreen = PEvergreen;
}}
2(a)(i) VB.NET
Class Tree
Private TreeName As String
Private HeightGrowth As Integer
Private MaxHeight As Integer
Private MaxWidth As Integer
Private Evergreen As String
Sub New(Name, HGrowth, MaxH, MaxW, PEvergreen)
TreeName = Name
HeightGrowth = HGrowth
MaxHeight = MaxH
MaxWidth = MaxW
Evergreen = PEvergreen
End Sub
End Class
Python
class Tree:
def __init__(self, Name, HGrowth, MaxH, MaxW, PEvergreen):
self.__TreeName = Name
self.__HeightGrowth = HGrowth
self.__MaxHeight = MaxH
self.__MaxWidth = MaxW
self.__Evergreen = PEvergreen
2(a)(ii) VB.NET
Function GetTreeName()
Return TreeName
End Function
Function GetMaxHeight()
Return MaxHeight
End Function
Function GetMaxWIdth()
Return MaxWidth
End Function
Function GetGrowth()
Return HeightGrowth
End Function
Function GetEvergreen()
Return Evergreen
End Function
Python
def GetTreeName(self):
return self.__TreeName
def GetMaxHeight(self):
return self.__MaxHeight
def GetMaxWidth(self):
return self.__MaxWidth
def GetGrowth(self):
return self.__HeightGrowth
def GetEvergreen(self):
return self.__Evergreen
}catch(FileNotFoundException e){
System.out.println("File not found");
}
return TreeData;
}
2(b) VB.NET
Function ReadData()
Dim TreeObjects(10) As Tree
Dim TextFile As String = "Trees.txt"
try
Dim FileReader As New System.IO.StreamReader(TextFile)
Dim TreeData(10) As String
Dim TreeSplit() As String
For Count = 0 To 8
TreeData(Count) = FileReader.ReadLine()
Next Count
FileReader.Close()
For X = 0 To 8
TreeSplit = TreeData(X).Split(",")
TreeObjects(X) = New Tree(TreeSplit(0), Integer.Parse(TreeSplit(1)),
Integer.Parse(TreeSplit(2)), Integer.Parse(TreeSplit(3)), TreeSplit(4))
Next X
Catch ex As Exception
Console.WriteLine ("invalid file")
End Try
Return TreeObjects
End Function
2(b) Python
def ReadData():
TreeObjects=[]
try:
File = open("Trees.txt")
TreeData = []
TreeData = File.read().split("\n")
SplitTrees = []
for Item in TreeData:
SplitTrees.append(Item.split(","))
File.close()
for Item in SplitTrees:
TreeObjects.append(Tree(Item[0],int(Item[1]),int(Item[2]),int(Item[3]),Item[4]))
except IOError:
print ("invalid file")
return TreeObjects
e.g.
Java
public static void PrintTrees(Tree TreeItem){
String Final = "does not lose its leaves";
if((TreeItem.GetEvergreen()).compareTo("No") == 0){
Final = "loses its leaves each year";
}
System.out.println(TreeItem.GetTreeName() + " has a maximum height " +
TreeItem.GetMaxHeight() + " a maximum width " + TreeItem.GetMaxWidth() + " and grows " +
TreeItem.GetGrowth() + " cm a year. It " + Final);
}
VB.NET
Sub PrintTrees(Item)
Dim Final As String = "does not lose its leaves"
If (Item.GetEvergreen() = "No") Then
Final = "loses its leaves each year"
End If
Console.WriteLine(Item.GetTreeName() & " has a maximum height " &
Item.GetMaxHeight() & " a maximum width " & Item.GetMaxWidth() & " and grows " &
Item.GetGrowth() & "cm a year. It" & Final)
End Sub
2(c) Python
def PrintTrees(Item):
e.g.
Java
Tree[] TreeData = new Tree[20];
TreeData = ReadData();
PrintTrees(TreeData[0]);
VB.NET
Sub Main(args As String())
Dim TreeObjects(10) As Tree
TreeObjects = ReadData()
PrintTrees(Treeobjects(0))
End Sub
Python
TreeObjects = ReadData()
PrintTrees(TreeObjects[0])
e.g.
Java
public static void ChooseTree(Tree[] Trees){
Scanner scanner = new Scanner(System.in);
System.out.println("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)") ;
String Evergreen = (scanner.nextLine());
System.out.println("What is the maximum tree height in cm");
Integer MaxHeight = Integer.parseInt(scanner.nextLine());
System.out.println("What is the maximum tree width in cm");
Integer MaxWidth = Integer.parseInt(scanner.nextLine());
Tree[] Options = new Tree[20];
String keep;
Tree Selected;
Boolean Valid = false;
if(((Evergreen.toLowerCase()).compareTo("keep") == 0) ||
((Evergreen.toLowerCase()).compareTo("keep leaves") == 0) ||
((Evergreen.toLowerCase()).compareTo("keeps its leaves") == 0)){
keep = "Yes";
}else{
keep = "No";
}
Integer Counter = 0;
for(Integer X = 0; X < 9; X++){
VB.NET
Sub ChooseTree(Trees)
Console.WriteLine("Do you want a tree that loses its leaves (enter lose), or keeps
its leaves (enter keep)")
Dim Evergreen As String = Console.ReadLine()
Console.WriteLine("What is the maximum tree height in cm")
Dim MaxHeight As Integer = Console.ReadLine()
Console.WriteLine("What is the maximum tree width in cm")
Dim MaxWidth As Integer = Console.ReadLine()
Dim Options(0 To 9) As Tree
Dim keep As String
Dim Valid As Boolean
Dim Selected As Tree
If Evergreen.ToLower() = "keep" Or Evergreen.ToLower() = "keep leaves" Or
Evergreen.ToLower() = "keeps its leaves" Then
keep = "Yes"
Else
keep = "No"
2(e)(i) End If
Dim count As Integer = 0
For x = 0 To 8
If Trees(x).GetMaxHeight() <= MaxHeight And Trees(x).GetMaxWidth() <= MaxWidth
And keep = Trees(x).GetEvergreen() Then
Options(count) = Trees(x)
PrintTrees(Trees(x))
count = count + 1
End If
Next x
If count = 0 Then
Console.WriteLine("No suitable trees")
End If
End Sub
Python
def ChooseTree(Trees):
Evergreen = input("Do you want a tree that loses its leaves (enter lose), or keeps its
leaves (enter keep)")
MaxHeight = int(input("What is the maximum tree height in cm"))
MaxWidth = int(input("What is the maximum tree width in cm"))
Options = []
if Evergreen.lower() == "keep" or Evergreen.lower() == "keep leaves" or
Evergreen.lower() == "keeps its leaves":
keep = "Yes"
else:
keep = "No"
for Item in Trees:
2(e)(ii) Java
Integer Start;
Float Height;
Float Growth;
Float Years;
while(Valid == false){
System.out.println("Enter the name of the tree you want");
String Choice = scanner.nextLine();
for(Integer X = 0; X < Counter; X++){
if((Options[X].GetTreeName()).compareTo(Choice)==0){
Valid = true;
Selected = Options[X];
System.out.println("Enter the height of the tree you would like to start
with in cm");
Start = Integer.parseInt(scanner.nextLine());
Height = (Selected.GetMaxHeight()).floatValue();
Growth = (Selected.GetGrowth()).floatValue();
Years = (Height - Start) / Growth;
System.out.println("Your tree should be full height in approximately "+
Years + " years");
}
}
}
Python:
Valid = False
while Valid == False:
Choice = input("Enter the name of the tree you want")
for Item in Options:
if Item.GetTreeName() == Choice:
Valid = True
Selected = Item
Start = int(input("Enter the height of the tree you would like to start with in
cm"))
Years = (Selected.GetMaxHeight() - Start)/Selected.GetGrowth()
print("Your tree should be full height in approximately", Years,"years")
3(a)(i) Python
class Character:
#self.XPosition integer
#self.YPosition integer
#self.Name string
Java
VB.NET
Function GetXPosition()
Return XPosition
End Function
Function GetYPosition()
Return YPosition
End Function
Python
def GetXPosition(self):
return self. XPosition
def GetYPosition(self):
return self. YPosition
Java
VB.NET
Function SetXPosition(Value)
XPosition = XPosition + Value
If XPosition > 10000 Then
XPosition = 10000
Python
Java
VB.NET
3(a)(iv) Python
Java
Character Jack = new Character(50, 50, "Jack");
VB.NET
Python
Java
class BikeCharacter extends Character{
public BikeCharacter(Integer XPositionP, Integer YPositionP, String NameP){
super(XPositionP, YPositionP, NameP);
}
}
VB.NET
Class BikeCharacter
Inherits Character
Python
class BikeCharacter(Character):
def init (self, XPositionP, YPositionP, NameP):
super(). init (XPositionP, YPositionP, NameP)
Java
VB.NET
Overrides Sub
Move(Direction) If
Direction = "up" Then
SetYPosition(20)
ElseIf Direction = "down" Then
SetYPosition(-20)
ElseIf Direction = "right" Then
SetXPosition(20)
ElseIf Direction = "left" Then
SetXPosition(-20)
End If
End Sub
3(c)(ii) Python
Java
VB.NET
Python
Karla = BikeCharacter(100, 50, "Karla")
Java
3(e)(i) VB.NET
3(e)(i) Python