Information Technology P1 Feb-March 2018 Memo Eng
Information Technology P1 Feb-March 2018 Memo Eng
SENIOR CERTIFICATE
GRADE12
INFORMATION TECHNOLOGY P1
FEBRUARY/MARCH 2018
MARKING GUIDELINES
MARKS: 150
GENERAL INFORMATION
These marking guidelines must be used as the basis for the marking session.
They were prepared for use by markers. All markers are required to attend a
rigorous standardisation meeting to ensure that the guidelines are consistently
interpreted and applied in the marking of candidates' work.
Note that learners who provide an alternate correct solution to that given as
example of a solution in the marking guidelines will be given full credit for the
relevant solution, unless the specific instructions in the question paper were not
followed or the requirements of the question were not met.
Annexures A, B and C (pages 3–8) include the marking grid for each question
and a table for a summary of the learner’s marks.
ANNEXURE A
SECTION A
ANNEXURE B
SECTION B
QUESTION 2: MARKING GRID - OBJECT-ORIENTED PROGRAMMING
ANNEXURE C
SECTION C
QUESTION 3: MARKING GRID – PROBLEM SOLVING PROGRAMMING
TOTAL SECTION C: 40
LEARNER'S
MARKS
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, jpeg, DateUtils, Math;
type
TfrmQ1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Image1: TImage;
btnQ1_1: TButton;
redQ1_1: TRichEdit;
edtRadius: TEdit;
edtBase: TEdit;
edtHeight: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label7: TLabel;
lblInfo: TLabel;
Label9: TLabel;
edtQues1_2: TEdit;
btnQ1_2: TButton;
Image2: TImage;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
TabSheet6: TTabSheet;
edtSentence: TEdit;
Label10: TLabel;
btnQ1_4: TButton;
edtRemoveVowels: TEdit;
Label11: TLabel;
Label12: TLabel;
edtNum1: TEdit;
edtNum2: TEdit;
btnQ1_3: TButton;
edtHCF: TEdit;
redQues1_5: TRichEdit;
btnQ1_5: TButton;
procedure btnQ1_1Click(Sender: TObject);
procedure btnQ1_2Click(Sender: TObject);
procedure btnQ1_3Click(Sender: TObject);
procedure btnQ1_5Click(Sender: TObject);
procedure btnQ1_4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ1: TfrmQ1;
implementation
{$R *.dfm}
// =====================================================================
// Question 1.1
// =====================================================================
procedure TfrmQ1.btnQ1_1Click(Sender: TObject);
Const
rPi = 3.14159;
iNumber = 8;
Var
rRadius, rAreaCircle, rBase, rHeight, rAreaTriangles, rTotalArea:
real;
begin
rRadius := StrToFloat(edtRadius.Text);
rBase := StrToFloat(edtBase.Text);
rHeight := StrToFloat(edtHeight.Text);
rAreaCircle := rPi * Sqr(rRadius);
redQ1_1.Lines.Add('Area of circle = ' + FloatToStr(rAreaCircle));
rAreaTriangles := 0.5 * rBase * rHeight * iNumber;
redQ1_1.Lines.Add('Total area of triangles = '+
FloatToStr(rAreaTriangles));
rTotalArea := rAreaCircle + rAreaTriangles;
redQ1_1.Lines.Add('Total area = ' +
FloatToStrF(rTotalArea, ffFixed, 6, 2));end;
// =====================================================================
// Question 1.2
// =====================================================================
procedure TfrmQ1.btnQ1_2Click(Sender: TObject);
Const
iIncrease = 3;
Var
dDate: TDateTime;
iColon, iMoonYear: integer;
begin
iColon := pos(':',lblInfo.Caption);
iMoonYear := StrToInt(copy(lblInfo.Caption, iColon+1, 4));
repeat
iMoonYear := iMoonYear + iIncrease;
until iMoonYear > YearOf(now);
edtQues1_2.Text := IntToStr(iMoonYear);
end;
// =====================================================================
// Question 1.3
// =====================================================================
procedure TfrmQ1.btnQ1_3Click(Sender: TObject);
Var
iNum1, iNum2, iHcf, iLoop, i: integer;
begin
iNum1 := StrToInt(edtNum1.Text);
iNum2 := StrToInt(edtNum2.Text);
for i := 1 to Min(iNum1, iNum2) do
begin
if (iNum1 mod i = 0) and (iNum2 mod i = 0) then
begin
iHcf := i;
end;
end;
edtHCF.Text := IntToStr(iHcf);
end;
// =====================================================================
// Question 1.4
// =====================================================================
procedure TfrmQ1.btnQ1_4Click(Sender: TObject);
Var
sSent, sTemp: String;
i: integer;
begin
sSent := edtSentence.Text;
sTemp := sSent[1];
for i := 2 to length(sSent) do
begin
if (sSent[i - 1] = ' ') OR
NOT(upcase(sSent[i]) in ['A', 'E', 'I', 'O', 'U']) then
sTemp := sTemp + sSent[i];
end;
edtRemoveVowels.Text := sTemp;
end;
// =====================================================================
// Question 1.5
// =====================================================================
procedure TfrmQ1.btnQ1_5Click(Sender: TObject);
Const
iSeatsAvailable = 100;
Var
iGroupNumber, iNumPeople, iTotal: integer;
begin
// Provided code
redQues1_5.Clear;
redQues1_5.Lines.Add('Group number' + #9#9 + 'Number of people');
iTotal := 0;
iGroupNumber := 0;
OBJECT CLASS:
unit Star_U;
interface
type
TStar = class(TObject)
private
// Provided code - attribute declaration
fName: String;
fMagnitude: real;
fDistance: integer;
fConstellation: String;
fNavigationalStatus: Boolean;
public
constructor Create(Name: String; Magnitude: real; Distance: integer;
Constellation: String);
function getConstellation: String;
procedure setNavigationalStatus(bStatus: Boolean);
function determineVisibilty: String;
function toString: String;
// Provided code
function getName: String;
end;
implementation
// =====================================================================
// Question 2.1.1
// =====================================================================
constructor TStar.Create(sName: String; rMagnitude: real; iDistance:
integer; sConstellation: String);
begin
fName := sName;
fMagnitude := rMagnitude;
fDistance := iDistance;
fConstellation := sConstellation;
fNavigationalStatus := false;
end;
// =====================================================================
// Question 2.1.2
// =====================================================================
function TStar.getConstellation: String;
begin
result := fConstellation;
end;
// =====================================================================
// Question 2.1.3
// =====================================================================
procedure TStar.setNavigationalStatus(bStatus: Boolean);
begin
fNavigationalStatus := bStatus;
end;
// =====================================================================
// Question 2.1.4
// =====================================================================
function TStar.determineVisibilty: String;
var
sVisibility: String;
begin
if (fDistance < 80)then
sVisibility := 'Clearly visible'
else
if (fDistance <= 900) then
if (fMagnitude <= 2)then
sVisibility := 'Hardly visible to the naked eye'
else
sVisibility := 'Only visible by means of standard optical aid'
else
sVisibility := 'Only visible by means of specialised optical aid';
Result := sVisibility;
end;
// =====================================================================
// Question 2.1.5
// =====================================================================
function TStar.toString: String;
var
sOutput: String;
begin
sOutput := Format('%s belongs to the' + ' %s constellation.' + #13 +
#13 + 'The star has a magnitude of %3.2f and is %d light
years away from Earth.' + #13+ #13,
[fName, fConstellation, fMagnitude, fDistance]);
if fNavigationalStatus then
sOutput := sOutput + fName + ' is a navigational star.'
else
sOutput := sOutput + fName + ' is a passive star.';
result := sOutput;
end;
// =====================================================================
// Provided code
// =====================================================================
function TStar.getName: String;
begin
result := fName;
end;
end.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, jpeg, Star_U;
type
TfrmQ2 = class(TForm)
bmbClose: TBitBtn;
btnQ2_2_1: TButton;
redOutput: TRichEdit;
lblHeading: TLabel;
cmbStar: TComboBox;
imgQ2: TImage;
pnlButtons: TPanel;
lblQstNum: TLabel;
btnQ2_2_2: TButton;
btnQ2_2_3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight:
Integer;
var Resize: Boolean);
procedure cmbStarChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ2: TfrmQ2;
// Provided code
objStarX: TStar;
implementation
var
arrNavigationStars: array [1 .. 58] of String = (
'Alpheratz','Ankaa','Schedar','Diphda','Achernar','Hamal','Acamar',
'Menkar','Mirfak','Aldebaran','Rigel','Capella','Bellatrix','Elnath',
'Alnilam','Betelgeuse','Canopus','Sirius','Adhara','Procyon','Pollux',
'Avior','Suhail','Miaplacidus','Alphard','Regulus','Dubhe','Denebola',
'Gienah','Acrux','Gacrux','Alioth','Spica','Alkaid','Hadar','Menkent',
'Rigil Kentaurus','Arcturus','Zubenelgenubi','Kochab','Alphecca',
'Antares','Atria','Sabik','Shaula','Rasalhague','Eltanin',
'Kaus Australis','Vega','Nunki','Altair','Peacock','Deneb','Enif',
'Al Na''ir','Fomalhaut','Markab','Polaris');
{$R *.dfm}
{$R+}
// Question 2.2.1
// =====================================================================
procedure TfrmQ2.btnQ2_2_1Click(Sender: TObject);
var
sStarName: String;
tFile: textFile;
sLine, sConstellation: String;
rMagnitude : real;
bFoundFile, bFoundArray: Boolean;
A, iDistance : Integer;
begin
// Question 2.2.1
sStarName := cmbStar.Items[cmbStar.ItemIndex];
AssignFile(tFile, 'StarData.txt');
Reset(tFile);
bFoundFile := false;
While NOT Eof(tFile) AND NOT bFoundFile do
begin
Readln(tFile, sLine);
if Trim(sStarName) = Trim(sLine) then
begin
Readln(tFile, rMagnitude);
Readln(tFile, iDistance);
Readln(tFile, sConstellation);
objStarX := TStar.Create(sStarName, rMagnitude, iDistance,
sConstellation);
bFoundArray := false;
for A := 1 to Length(arrNavigationStars) do
If pos(arrNavigationStars[A], objStarX.getName) > 0 then
bFoundArray := true;
objStarX.setNavigationalStatus(bFoundArray);
bFoundFile := true;
pnlButtons.Show;
end;
end;
if NOT bFoundFile then
begin
sLine := 'The star was not found in the file.';
MessageDlg(sLine, mtError, [mbOK], 0);
pctrlQ2.ActivePageIndex := 1;
pnlButtons.Hide;
end;
CloseFile(tFile);
end;
// Question 2.2.2
// =====================================================================
procedure TfrmQ2.btnQ2_2_2Click(Sender: TObject);
begin
// Question 2.2.2
redOutput.Clear; //Provided code
redOutput.Lines.Add(objStarX.toString);
imgQ2.Picture.LoadFromFile(objStarX.getConstellation + '.jpg');
end;
// =====================================================================
// Question 2.2.3
// =====================================================================
procedure TfrmQ2.btnQ2_2_3Click(Sender: TObject);
begin
// Question 2.2.3
redOutput.Clear;
redOutput.Paragraph.TabCount := 1;
redOutput.Paragraph.Tab[0] := 50;
redOutput.Lines.Add('Star:' + #9 +objStarX.getName);
redOutput.Lines.Add('Visibility: ' +#9 + objStarX.determineVisibilty);
end;
end.
unit Question3_U;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons;
type
TfrmQ3 = class(TForm)
redQ3GameBoard: TRichEdit;
rgbQ3: TRadioGroup;
btnQ3_1StartGame: TButton;
btnClose: TBitBtn;
btnQ3_2Play: TButton;
cmbRow: TComboBox;
cmbCol: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
redQ3Incorrect: TRichEdit;
btnQ3_3Reveal: TButton;
Label5: TLabel;
pnlQ3NumberOfGuesses: TPanel;
pnlPlay: TPanel;
procedure btnQ3_1StartGameClick(Sender: TObject);
procedure populate;
procedure display;
procedure btnQ3_2PlayClick(Sender: TObject);
procedure btnQ3_3RevealClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ3: TfrmQ3;
iNum: integer;
iFound: integer = 0;
iCount: integer;
// ===================================================================
// Provided code
// ===================================================================
arrGame: array [1..9, 1..9] of char;
implementation
{$R *.dfm}
{$R+}
// ===================================================================
// Question 3.1
// ===================================================================
procedure TfrmQ3.btnQ3_1StartGameClick(Sender: TObject);
var
iLevel: integer;
begin
// Question 3.1
iLevel := rgbQ3.ItemIndex;
case iLevel of
0: iNum := 50;
1: iNum := 40;
2: iNum := 30;
end;
iFound := 0;
iCount := 0;
pnlQ3NumberOfGuesses.Caption := IntToStr(iFound);
btnQ3_2Play.Enabled := true;
redQ3Incorrect.Clear;
cmbRow.ItemIndex:=0;
cmbCol.ItemIndex:=0;
populate;
display;
end;
procedure TfrmQ3.populate;
var
iRow, iCol: integer;
begin
for iRow := 1 to Length(arrGame) do
begin
for iCol := 1 to Length(arrGame) do
begin
arrGame[iRow, iCol] := '-';
end;
end;
procedure TfrmQ3.display;
var
iRow, iCol: integer;
sLine: String;
begin
redQ3GameBoard.Clear;
for iRow := 1 to Length(arrGame) do
begin
sLine := '';
for iCol := 1 to Length(arrGame) do
begin
if arrGame[iRow, iCol] = '$' then
sLine := sLine + '# '
else
sLine := sLine + '- ';
end;
redQ3GameBoard.Lines.Add(sLine);
end;
end;
// ===================================================================
// Question 3.2
// ===================================================================
procedure TfrmQ3.btnQ3_2PlayClick(Sender: TObject);
var
iRow, iCol: integer;
cChar: char;
begin
// Question 3.2
iRow := StrToInt(cmbRow.text);
iCol := StrToInt(cmbCol.text);
cChar := arrGame[iRow, iCol];
Inc(iCount);
if cChar = '#' then
begin
arrGame[iRow, iCol] := '$';
Inc(iFound);
end
else
begin
redQ3Incorrect.Lines.Add('R' + IntToStr(iRow) + ', C' +
IntToStr(iCol));
end;
display;
pnlQ3NumberOfGuesses.Caption := IntToStr(iCount);
// ===================================================================
// Question 3.3
// ===================================================================
procedure TfrmQ3.btnQ3_3RevealClick(Sender: TObject);
var
iRow, iCol: integer;
sLine: String;
begin
// Question 3.3
redQ3GameBoard.Clear;
for iRow := 1 to Length(arrGame) do
begin
sLine := '';
for iCol := 1 to Length(arrGame) do
begin
sLine := sLine + arrGame[iRow, iCol] + ' ';
end;
redQ3GameBoard.Lines.Add(sLine);
end;
end;
end.
Copyright reserved