IT March 2014 Paper 1 MEMO
IT March 2014 Paper 1 MEMO
SENIOR CERTIFICATE
GRADE 12
INFORMATION TECHNOLOGY P1
FEBRUARY/MARCH 2014
MEMORANDUM
MARKS: 120
GENERAL INFORMATION:
• These marking guidelines are to be used as the basis for the marking session.
They were prepared for use by markers.
• Note that candidates who provide an alternate correct solution to that given in
the marking guidelines will be given full credit for the relevant question.
• Annexures A, B and C (pages 3-7) include the marking grid for each question
for using either one of the two programming languages.
• Annexures D, E, F and G (pages 8-20) contain the solutions for Delphi for
Questions 1 to 3 in programming code.
• Annexures H, I, J and K (pages 21-33) contain the solutions for Java for
Questions 1 to 3 in programming code.
ANNEXURE A:
Alternative: Format(AVG(NumMobileDevices),"#.00")
Alternative: Format(AVG(NumMobileDevices),"0.00")
Alternative: Format(AVG(NumMobileDevices),".00")
5
Alternative: Round(AVG(NumMobileDevices),2)
Alternative: Format(AVG(NumMobileDevices),'#.00')
Alternative: Format(AVG(NumMobileDevices),'0.00')
Alternative: Format(AVG(NumMobileDevices),'.00')
Alternative: ROUND(AVG(NumMobileDevices), 2)
ANNEXURE B:
Output for best male and best female (name and average);
Format average to 2 decimal places
ANNEXURE C:
QUESTION 3: MARKING GRID – PROBLEM-SOLVING PROGRAMMING
unit Question1U_MEMO;
//A solution for Question 1
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids, ExtCtrls, Buttons, Menus;
type
TfrmQ1 = class(TForm)
qryQ1: TADOQuery;
dsrQry: TDataSource;
grdQ1: TDBGrid;
mnuMain: TMainMenu;
mnuOptionA: TMenuItem;
mnuOptionB: TMenuItem;
mnuOptionC: TMenuItem;
mnuOptionD: TMenuItem;
mnuOptionE: TMenuItem;
mnuOptionF: TMenuItem;
mnuOptionG: TMenuItem;
mnuQuit: TMenuItem;
procedure mnuOptionAClick(Sender: TObject);
procedure mnuOptionBClick(Sender: TObject);
procedure mnuOptionCClick(Sender: TObject);
procedure mnuOptionDClick(Sender: TObject);
procedure mnuOptionEClick(Sender: TObject);
procedure mnuOptionFClick(Sender: TObject);
procedure mnuOptionGClick(Sender: TObject);
procedure mnuQuitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ1: TfrmQ1;
implementation
{$R *.dfm}
//========================================================================
procedure TfrmQ1.mnuOptionAClick(Sender: TObject);
begin
qryQ1.Close;
qryQ1.SQL.Text := 'SELECT * FROM tblRespondents ORDER BY QuestID DESC';
qryQ1.Open;
end;
//========================================================================
procedure TfrmQ1.mnuOptionBClick(Sender: TObject);
begin
qryQ1.Close;
qryQ1.SQL.Text := 'SELECT QuestID, DateSubmitted, StudentID '+
'FROM tblRespondents ' +
'WHERE DateSubmitted > #2013/08/07#';
qryQ1.Open;
end;
//========================================================================
end;
//========================================================================
procedure TfrmQ1.mnuOptionGClick(Sender: TObject);
begin
qryQ1.Close;
qryQ1.SQL.Text := 'DELETE FROM tblRespondents '+
'WHERE InternetContract = False AND ' +
'ConnectionType IS NOT NULL';
qryQ1.ExecSQL;
MessageDlg('Records Processed Successfully',mtInformation,[mbOk],0);
end;
//========================================================================
procedure TfrmQ1.mnuQuitClick(Sender: TObject);
begin
Application.Terminate;
end;
end.
unit uStudent_Memo;
//A solution for Question 2 - Class unit.
interface
TYPE
TStudent = class(TObject)
private
fName : String;
fGender : Char;
fQuestionnaires : Integer;
fHours : Real;
public
constructor Create(sName:String; cGender:Char; iQuestionnaires:Integer;
rHours:Real);
function calcAvg : Real;
function toString : String;
implementation
uses SysUtils;
{ TStudent }
end.
unit Question2U_Memo;
//A solution for Question 2 - Main Form Unit.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Menus,
uStudent_Memo;
type
TfrmQ2 = class(TForm)
mnuMain: TMainMenu;
mnuOptionA: TMenuItem;
mnuQuit: TMenuItem;
redQ2: TRichEdit;
mnuOptionB: TMenuItem;
mnuOptionC: TMenuItem;
procedure mnuQuitClick(Sender: TObject);
procedure mnuOptionAClick(Sender: TObject);
procedure mnuOptionBClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure mnuOptionCClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ2: TfrmQ2;
arrData : array[1..20] of TStudent;
iCounter : Integer;
Copyright reserved Please turn over
Information Technology/P1 12 DBE/Feb.–Mar. 2014
NSC – Memorandum
implementation
{$R *.dfm}
{$R+}
end.
Copyright reserved Please turn over
Information Technology/P1 14 DBE/Feb.–Mar. 2014
NSC – Memorandum
type
TPlayer = class(TObject)
private
fGameName : String;
fDevice : String;
public
constructor Create(sGName, sDevice : String);
procedure SetGameName(sGName : String);
function GetGameName : String;
procedure SetDevice(sDevice : String);
function GetDevice : String;
function toString : String;
end;
implementation
{ TPlayer}
Uses SysUtils;
end.
unit Question3OOP_U;
//An OOP solution for Question 3
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ComCtrls;
type
TfrmQ3memo = class(TForm)
redQ3: TRichEdit;
mmuMain: TMainMenu;
mnuOptionA: TMenuItem;
mnuQuit: TMenuItem;
procedure mnuQuitClick(Sender: TObject);
procedure mnuOptionAClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQ3memo: TfrmQ3memo;
implementation
{$R *.dfm}
{$R+}
uses uPlayer;
var
arrData : array[1..35] of String =
('Civilisation#PS3', 'Command & Conquer#PC', 'Solitaire#Xbox',
'Chess#PC', 'Tetris#PC', 'Chess#PC', 'Command & Conquer#PC',
'Civilisation#PC', 'SimCity#PC', 'Tetris#PC', 'SimCity#PC',
'Civilisation#PS3', 'Tetris#PS3', 'Command & Conquer#PS3',
'SimCity#PC', 'Solitaire#PC', 'Sims#Xbox', 'SimCity#Xbox',
'Command & Conquer#PC', 'Chess#PS3', 'Tetris#Xbox',
'Civilisation#Xbox', 'SimCity#PS3', 'Solitaire#PC',
'Sims#Xbox', 'Command & Conquer#PS3', 'Command & Conquer#PS3',
'Civilisation#PS3', 'Civilisation#PS3', 'Command & Conquer#Xbox',
'SimCity#PS3', 'Solitaire#PS3', 'Civilisation#Xbox',
'Command & Conquer#PC', 'SimCity#PC');
procedure CreatePlayerObjects;
var
A : Integer;
sGName, sDevice : String;
begin
for A := 1 to length(arrData) do
begin
sGName := copy(arrData[A], 1, Pos('#', arrData[A])-1);
sDevice := copy(arrData[A], Pos('#', arrData[A])+1, 5);
Copyright reserved Please turn over
Information Technology/P1 16 DBE/Feb.–Mar. 2014
NSC – Memorandum
procedure CreateGamesArray;
var
A, B : Integer;
sGName : String;
bFound : Boolean;
begin
for A := 1 to length(arrGames) do
arrGames[A] := '';
iGCounter := 0;
for A := 1 to length(arrData) do
begin
sGName := arrPlayers[A].GetGameName;
bFound := False;
B := 1;
while (B < length(arrGames)) and NOT bFound do
begin
IF sGName = arrGames[B] then
bFound := True
else Inc(B, 1);
end; //while
IF NOT bFound then
begin
Inc(iGCounter, 1);
arrGames[iGCounter] := sGName;
end; //if
end; //for A
end;
for A := 1 to iGCounter do
redQ3.Lines.Add(IntToStr(A) + '. ' + arrGames[A]);
repeat
iGameNo := StrToInt(InputBox('Question 3', 'Enter the number of a game from the
list', '1'));
IF NOT(iGameNo IN [1..iGCounter]) then
ShowMessage('Invalid input'); // Of MessageDialog ...
until iGameNo in [1..iGCounter];
sGName := arrGames[iGameNo];
processData(iGameNo,iPC,iXbox,iPS3,iCount);
redQ3.Lines.Clear;
redQ3.Paragraph.TabCount := 2;
redQ3.Paragraph.Tab[0] := 50;
redQ3.Paragraph.Tab[1] := 100;
redQ3.Lines.Add(sGName + ' was mentioned ' + IntToStr(iCount)+ ' times.');
redQ3.Lines.Add(' ');
redQ3.Lines.Add('Percentage use of devices:');
redQ3.Lines.Add('PS3' + #9 + 'Xbox' + #9 + 'PC');
redQ3.Lines.Add(FloatToStrF(iPS3/iCount*100, ffFixed, 5,1) + '%' + #9 +
FloatToStrF(iXbox/iCount*100, ffFixed, 5,1) + '%' + #9 +
FloatToStrF(iPC/iCount*100, ffFixed, 5,1) + '%');
end;
end.
unit Question3U_MEMO;
//A solution for Question 3 (without OOP).
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ComCtrls;
type
TfrmQ3 = class(TForm)
redQ3: TRichEdit;
mnuMain: TMainMenu;
mnuOptionA: TMenuItem;
mnuQuit: TMenuItem;
procedure mnuOptionAClick(Sender: TObject);
procedure mnuQuitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
{$R+}
var
frmQ3: TfrmQ3;
arrData : array[1..35] of String =
('Civilisation#PS3', 'Command & Conquer#PC', 'Solitaire#Xbox',
'Chess#PC', 'Tetris#PC', 'Chess#PC', 'Command & Conquer#PC',
'Civilisation#PC', 'SimCity#PC', 'Tetris#PC', 'SimCity#PC',
'Civilisation#PS3', 'Tetris#PS3', 'Command & Conquer#PS3',
'SimCity#PC', 'Solitaire#PC', 'Sims#Xbox', 'SimCity#Xbox',
'Command & Conquer#PC', 'Chess#PS3', 'Tetris#Xbox',
'Civilisation#Xbox', 'SimCity#PS3', 'Solitaire#PC',
'Sims#Xbox', 'Command & Conquer#PS3', 'Command & Conquer#PS3',
'Civilisation#PS3', 'Civilisation#PS3', 'Command & Conquer#Xbox',
'SimCity#PS3', 'Solitaire#PS3', 'Civilisation#Xbox',
'Command & Conquer#PC', 'SimCity#PC');
procedure CreateGamesArray;
var
A, B : Integer;
bFound : Boolean;
sGName : String;
begin
for A := 1 to length(arrGames) do
arrGames[A] := '';
iGCounter := 0;
for A := 1 to length(arrData) do
begin
sGName := Copy(arrData[A], 1, Pos('#', arrData[A])-1);
bFound := False;
B := 1;
while (B < arrSpeletjies) AND NOT bFound do
begin
IF sGName = arrGames[B]then
bFound := True
else Inc(B, 1);
end; //while
IF NOT bFound then
begin
Inc(iGCounter, 1);
arrGames[iGCounter] := sGName;
end; //if
end; //for A
end;
sGName := arrGames[iGameNo];
redQ3.Paragraph.TabCount := 2;
redQ3.Paragraph.Tab[0] := 50;
redQ3.Paragraph.Tab[1] := 100;
end.
public StudentMemo( String name, char gender, int questionnaires, double hours) {
this.name = name;
this.gender = gender;
this.questionnaires = questionnaires;
this.hours = hours;
}
int counter = 0;
StudentMemo[] arrData = new StudentMemo[20];
// try {
sf = new Scanner(new FileReader("DataQ2.txt"));
char choice;
do {
System.out.println(" MENU\n");
System.out.println("Option A");
System.out.println("Option B");
System.out.println("Option C");
System.out.println("");
System.out.println("Q - QUIT");
System.out.println("\nYour choice? ");
choice = sc.nextLine().toUpperCase().charAt(0);
// OR choice = kb.readLine().toUpperCase().charAt(0);
switch (choice) {
case 'A':
// display array using toString method
System.out.println("List of students\n");
for (int count = 0; count < counter; count++) {
System.out.println(arrData[count]);
}
break;
case 'B':
DecimalFormat df = new DecimalFormat("0.00");
String nameM = "";
String nameF = "";
double highM = 0;
double highF = 0;
for (int count = 0; count < counter; count++)
{
double avg = arrData[count].avgNum();
if (arrData[count].getGender() == 'M' && avg > highM)
{
highM = avg;
nameM = arrData[count].getName();
}
if (arrData[count].getGender() == 'F' && avg > highF)
{
highF = avg;
nameF = arrData[count].getName();
}
}
System.out.println("Students with the highest average values:\n");
System.out.println("Male: " + nameM + " with an average of " +
df.format(highM)+ "\n");
System.out.println("Female: " + nameF + " with an average of " +
df.format(highF) + "\n");
break;
case 'C':
System.out.println("Name of student: ");
String name = sc.nextLine();
// OR String name = kb.readLine();
else
count++;
}
if (found == false) {
System.out.println("The student is not on the list");
}
else
{
System.out.println(arrData[count].toString());
}
break;
case 'Q':
System.out.println("Quit");
}
} while (choice != 'Q');
}
}
obj.populateArr(arrData);
obj.createGamesArray();
String[] arrData =
{"Civilisation#PS3", "Command & Conquer#PC", "Solitaire#Xbox",
"Chess#PC", "Tetris#PC", "Chess#PC", "Command & Conquer#PC",
"Civilisation#PC", "SimCity#PC", "Tetris#PC", "SimCity#PC",
"Civilisation#PS3", "Tetris#PS3", "Command & Conquer#PS3",
"SimCity#PC", "Solitaire#PC", "Sims#Xbox", "SimCity#Xbox",
"Command & Conquer#PC", "Chess#PS3", "Tetris#Xbox",
"Civilisation#Xbox", "SimCity#PS3", "Solitaire#PC","Sims#Xbox",
"Command & Conquer#PS3", "Command & Conquer#PS3", "Civilisation#PS3",
"Civilisation#PS3", "Command & Conquer#Xbox", "SimCity#PS3",
"Solitaire#PS3", "Civilisation#Xbox", "Command & Conquer#PC",
"SimCity#PC"};
if (found == false)
{
arrGames[number] = temp[0];
number++;
}
}
}
if (arrData[k].indexOf("Xbox")>0)
{
xBox++;
}
}
}
// output
double tot = pc + ps3 + xBox;
System.out.println("\n\n");
System.out.println(game + " was mentioned " + tot + " times." );
System.out.println("");
System.out.println("Percentage use of devices:");
String headings =String.format("%-20s%-20s%-20s", "PS3","Xbox", "PC");
String outString = String.format("%-3.1f%-16s%-3.1f%-16s%-3.1f%-16s",
s3/tot* 100), "%",(xBox /tot * 100), "%", (pc/tot * 100), "%");
System.out.println(headings);
System.out.println(outString);
System.out.println("\n");
}
else
{
System.out.println("Quit");
}
break;
case 'Q':
System.out.println("Quit");
break;
}
} while (choice != 'Q');
}
}
Copyright reserved