# Information Technology Grade 12 P1 Supplementary 2014 Memo

> Grade 12 Information Technology Paper 1 memorandum from the Supplementary Exam 2014 (English), 33 pages. Read online or download the free PDF.

- Page: https://www.hlayiso.com/library/grade-12-information-technology-2014-supplementary-exam-memorandum-paper-1-english/385ed970-9d20-49c4-b853-bee0f465a475
- Updated: 2026-09-28
- Subject: Information Technology
- Grade: Grade 12
- Language: English
- Document type: Memorandum
- Year: 2014
- Exam period: Supplementary Exam
- Paper: 1
- Curriculum: CAPS
- Pages: 33

Breadcrumbs: [Home](https://www.hlayiso.com/) › [Library](https://www.hlayiso.com/library) › [Grade 12](https://www.hlayiso.com/library/grade-12) › [Information Technology](https://www.hlayiso.com/library/grade-12/information-technology) › [Information Technology Grade 12 P1 Supplementary 2014 Memo](https://www.hlayiso.com/library/grade-12-information-technology-2014-supplementary-exam-memorandum-paper-1-english/385ed970-9d20-49c4-b853-bee0f465a475)

## About this document

Information Technology · Grade 12 · Supplementary Exam · 2014 · English. Memorandum, 33 pages. Read online or download the PDF.

Read it free online on the page above; download the PDF from there.

## Document text

Text extracted from the PDF. Layout, diagrams and tables may not survive extraction.

### Page 1

NATIONAL
                          SENIOR CERTIFICATE

                                 GRADE 12

                      INFORMATION TECHNOLOGY P1

                          FEBRUARY/MARCH 2014

                               MEMORANDUM

MARKS: 120

                     This memorandum consists of 33 pages.

Copyright reserved                                           Please turn over

### Page 2

Information Technology/P1                    2                           DBE/Feb.–Mar. 2014
                                     NSC – Memorandum

GENERAL INFORMATION:

   •   These marking guidelines are to be used as the basis for the marking session.
       They were prepared for use by markers.

   •   All the markers are required to attend a rigorous standardisation meeting to
       ensure that the guidelines are consistently interpreted and applied in the
       marking of candidates’ practical work.

   •   It is acknowledged that there may be different views about some matters of
       emphasis or detail in the guidelines, and different interpretations of the
       application thereof.

   •   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.

   •   Copies of Annexures A, B and C (pages 3-7) should be made for each
       candidate and completed during the marking session.

Copyright reserved                                                           Please turn over

### Page 3

Information Technology/P1                      3                            DBE/Feb.–Mar. 2014
                                       NSC – Memorandum

ANNEXURE A:

QUESTION 1: MARKING GRID - PROGRAMMING AND DATABASE

CENTRE NUMBER:                              EXAMINATION NUMBER:
                                                                             MAX. CANDIDATE'S
QUESTION                             DESCRIPTION
                                                                            MARKS   MARKS
    1.1       Query:    Correct fields (or *); correct table;
                        ORDER BY DESC 
                                                                               3
              SQL:      SELECT * FROM tblRespondents ORDER BY
                        QuestID DESC
    1.2       Query:    Correct fields & table; WHERE DateSubmitted;
                        > #correct date# 
              SQL:      SELECT QuestID, DateSubmitted, StudentID FROM
                        tblRespondents WHERE DateSubmitted >
                                                                               3
                        #2013/08/07#

              Alternative:SELECT QuestID, DateSubmitted, StudentID FROM
                         tblRespondents WHERE Day(DateSubmitted) > 7
    1.3       Query: Correct fields & table;WHERE City ; LIKE;
                         variable; wildcards; Number of devices >= 2;
                         Internet contract
              SQL (D): SELECT City, NumMobileDevices, ConnectionType
                         FROM tblRespondents WHERE City LIKE “%' + sX +
                         '%” AND NumMobileDevices >= 2 AND
                         InternetContract = TRUE
                                                                               7
              SQL (J): SELECT City, NumMobileDevices, ConnectionType
                       FROM tblRespondents WHERE City LIKE '%" + sX +
                       "%' AND NumMobileDevices >= 2 AND
                       InternetContract = TRUE

              Alternative: yes/on/1 instead of true
    1.4       Query: Correct fields & table; Format & #0.00 ;
                         Average; AS AvgMobilePerCity GROUP BY
                         City
              SQL (D): SELECT City, FORMAT(AVG(NumMobileDevices),
                         “#0.00”) AS AvgMobilePerCity FROM tblRespondents
                         GROUP BY City

              Alternative: Format(AVG(NumMobileDevices),"#.00")
              Alternative: Format(AVG(NumMobileDevices),"0.00")
              Alternative: Format(AVG(NumMobileDevices),".00")
                                                                               5
              Alternative: Round(AVG(NumMobileDevices),2)

              SQL (J): SELECT City, FORMAT(AVG(NumMobileDevices),
                       '#0.00') AS AvgMobilePerCity FROM tblRespondents
                       GROUP BY City

              Alternative: Format(AVG(NumMobileDevices),'#.00')
              Alternative: Format(AVG(NumMobileDevices),'0.00')
              Alternative: Format(AVG(NumMobileDevices),'.00')
              Alternative: ROUND(AVG(NumMobileDevices), 2)

Copyright reserved                                                              Please turn over

### Page 4

Information Technology/P1                       4                              DBE/Feb.–Mar. 2014
                                        NSC – Memorandum

QUESTION 1: MARKING GRID - PROGRAMMING AND DATABASE – continued

   1.5       Query:    Correct fields; both tables; Count (any field); AS
                       NumQuestionnaires; WHERE clause linking both
                       tables on StudentID;
                       GROUP BY all fields
             SQL:      SELECT Name, Surname, YearOfStudy, COUNT(*) AS
                       NumQuestionnaires FROM tblRespondents, tblStudents
                       WHERE tblRespondents.StudentID =
                       tblStudents.StudentID GROUP BY Name, Surname,
                       YearOfStudy

             Alternative:Use aliases for table names:
                        SELECT Name, Surname, YearOfStudy, COUNT(*) AS
                        NumQuestionnaires FROM tblRespondents R,                   6
                        tblStudents S WHERE R.StudentID = S.StudentID
                        GROUP BY Name, Surname, YearOfStudy

             Alternative:Use JOIN notation:
                        SELECT Name, Surname, YearOfStudy, COUNT(*) AS
                        NumQuestionnaires FROM tblRespondents INNER JOIN
                        tblStudents ON tblRespondents.StudentID =
                        tblStudents.StudentID GROUP BY Name, Surname,
                        YearOfStudy

             NOTE:    May use LEFT JOIN or RIGHT JOIN as an alternative to
                      INNER JOIN
   1.6       Query: UPDATE both tables; SET ; correct increment ;
                      WHERE clause linking both tables on StudentID;
                      AND correct name and surname
             SQL (D): UPDATE tblRespondents, tblStudents SET
                      NumMobileDevices = NumMobileDevices + 1 WHERE
                      tblRespondents.StudentID = tblStudents.StudentID AND
                                                                                   5
                      Name = "Kabelo" AND Surname = "Mkosi"

             SQL (J): UPDATE tblRespondents, tblStudents SET
                      NumMobileDevices = NumMobileDevices + 1 WHERE
                      tblRespondents.StudentID = tblStudents.StudentID AND
                      Name = 'Kabelo' AND Surname = 'Mkosi'
   1.7       Query: DELETE ; correct table  ; WHERE no Internet
                      contract AND connectionType ; IS NOT NULL 
             SQL:     DELETE FROM tblRespondents WHERE                             6
                      InternetContract = False AND ConnectionType IS NOT
                      NULL
                                                                   TOTAL:         35

Copyright reserved                                                                 Please turn over

### Page 5

Information Technology/P1                         5                             DBE/Feb.–Mar. 2014
                                          NSC – Memorandum

ANNEXURE B:

QUESTION 2: MARKING GRID - OBJECT-ORIENTED PROGRAMMING

CENTRE NUMBER:                                 EXAMINATION NUMBER:
                                                                                 MAX. CANDIDATE'S
QUESTION                               DESCRIPTION
                                                                                MARKS   MARKS
   2.1.1      PARAMETERISED CONSTRUCTOR:
              Correct order and data type of parameters;                         3
              Assign four parameters
   2.1.2      calcAvg METHOD:
              Divide completed number of questionnaires by hours;                 2
              Return floating point value 
   2.1.3      toString METHOD:
              Labels; <eoln> or #13 character ;
              Display all attributes correctly (character ) (numerical )         4

              NOTE: May use private attributes/get methods
   2.2.1      INITIALISATION OF ARRAY:
              {DELPHI: AssignFile (1 mark), Reset (1 mark)
              JAVA:         Create object to read from file (1 mark);
                            instantiate object (1 mark) } ;
              Initialise loop counter 
              Loop to read through file;
                    Read a line from text file;
                    Read next THREE lines from text file;
                                                                                  14
                    Extract a character value from second line of text;
                    Convert third line of text into an integer value ;
                    Convert fourth line of text into a floating point value;
                    Instantiate object using parameterized constructor:
                          {object on left = ; class on right = ;
                          parameters: type and order }
                    Change array counter;
               Close the text file
   2.2.2      MENU OPTION A:
              Heading 
                                                                                   3
              Loop to read through array;
              Display data of objects from array using the toString() method
   2.2.3      MENU OPTION B:
              Initialize variables (averages of best male and female)
              Loop to step through array 
                  Use calcAvg method 
                  IF male (M)  AND calcAvg > highest male average
                  store name/position of highest and replace highest male        11
                  average with new highest value 
                  Repeat for female 

              Output for best male and best female (name and average);
              Format average to 2 decimal places

Copyright reserved                                                                  Please turn over

### Page 6

Information Technology/P1                          6                                    DBE/Feb.–Mar. 2014
                                           NSC – Memorandum

QUESTION 2: MARKING GRID - OBJECT-ORIENTED PROGRAMMING – continued

   2.2.4      MENU OPTION C:
              Input name, number of completed questionnaires and hours
              Initialise flag ; Initialise counter 
              Conditional loop (test array range AND flag)
                    IF name found 
                        change flag
                        set attributes at correct counter position in array using the      12
                        set methods ; adding values typed in; make use of get
                        method to retrieve previous value
                    Increment loop counter 

              Outside the loop:
              Message if student not in list 
                                                                            TOTAL:         49

Copyright reserved                                                                          Please turn over

### Page 7

Information Technology/P1                        7                               DBE/Feb.–Mar. 2014
                                         NSC – Memorandum

ANNEXURE C:
QUESTION 3: MARKING GRID – PROBLEM-SOLVING PROGRAMMING

CENTRE NUMBER:                                EXAMINATION NUMBER:
                                                                                  MAX. CANDIDATE'S
QUESTION                              DESCRIPTION
                                                                                 MARKS   MARKS
    3.1       Declare appropriate data structure (e.g. array) for unique names
              of games and a counter variable;
              Initialise array counter 
              Generate array with name of games:
              Loop to step through array (arrData)
                 Extract the name of the game (assign) (copy/indexOf)
                 (use position of #)
                 Initialise Boolean flag 
                 Loop to step through games array 
                      Test name of game equals data array element                18
                      If equal change Boolean flag 
                 Outside loop:
                       If not found 
                      Increment the games array's counter 
                       Assign the name of game to games array 
              Displaying the names of the games:
                 Loop through games array 
                 Display menu repeatedly 
                 Display names of games  from array 
    3.2       Accept user input (read from keyboard) 
              Repeat user input until valid input entered 
              Calculating statistics:
                 Declare and initialise counters for each device/total 
                 Identify correct game from array (arrGames) depending on
                 user input 
                 Loop through array (arrData) 
                     Test if selected game is in arrData element 
                     Increment total counter; Test for device as part of
                                                                                   18
                     array element ; Increment correct device counter;
                     Repeat for all three devices
              Display statistics:
                 Headings with the name of the selected game and total
                 number of times mentioned ;
                 Calculate percentage use of each device with formula:
                 Device counter/(total number of times mentioned) * 100
                 Display use of each device rounded to one decimal
                 Display concatenated info in one line 
                                                                     TOTAL:        36

SUMMARY OF CANDIDATE’S MARKS:
                            QUESTION 1        QUESTION 2            QUESTION 3          GRAND TOTAL
   MAX. MARKS                  35                49                    36                   120
CANDIDATE'S MARKS

Copyright reserved                                                                   Please turn over

### Page 8

Information Technology/P1                 8                      DBE/Feb.–Mar. 2014
                                  NSC – Memorandum

ANNEXURE D: SOLUTION FOR QUESTION 1: DELPHI

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;
//========================================================================

Copyright reserved                                                   Please turn over

### Page 9

Information Technology/P1                9                       DBE/Feb.–Mar. 2014
                                 NSC – Memorandum

procedure TfrmQ1.mnuOptionCClick(Sender: TObject);
var
  sX : String;
begin
  sX := INPUTBOX('Question 1', 'Enter the name or part of the name of a city?',
                                                                        'town');
  qryQ1.Close;
  qryQ1.SQL.Text := 'SELECT City, NumMobileDevices, ConnectionType ' +
                     'FROM tblRespondents ' +
                     'WHERE City LIKE "%'+sX+'%" AND ' +
                     'NumMobileDevices >= 2 AND InternetContract = TRUE';
  qryQ1.Open;
end;
//========================================================================
procedure TfrmQ1.mnuOptionDClick(Sender: TObject);
begin
  qryQ1.Close;
  qryQ1.SQL.Text := 'SELECT City, FORMAT(AVG(NumMobileDevices),"0.00") '+
                     'AS AvgMobilePerCity ' +
                     'FROM tblRespondents GROUP BY City';
  qryQ1.Open;
end;
//========================================================================
procedure TfrmQ1.mnuOptionEClick(Sender: TObject);
begin
  qryQ1.Close;
  qryQ1.SQL.Text := 'SELECT Name, Surname, YearOfStudy, COUNT(*) AS
                        NumQuestionnaires ' +
                      'FROM tblRespondents R, tblStudents S ' +
                      'WHERE (R.StudentID = S.StudentID) '+
                      'GROUP BY Name, Surname, YearOfStudy ';
  qryQ1.Open;
end;
//========================================================================
procedure TfrmQ1.mnuOptionFClick(Sender: TObject);
begin
  qryQ1.Close;
  qryQ1.SQL.Text := 'UPDATE tblRespondents, tblStudents '+
                     'SET NumMobileDevices = NumMobileDevices + 1 '+
                     'WHERE tblRespondents.StudentID = tblStudents.StudentID ' +
                     'AND Name = "Kabelo" AND Surname = "Mkosi"';
  qryQ1.ExecSQL;
  MessageDlg('Records Processed Successfully',mtInformation,[mbOk],0);

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.

Copyright reserved                                                   Please turn over

### Page 10

Information Technology/P1                 10                         DBE/Feb.–Mar. 2014
                                   NSC – Memorandum

ANNEXURE E: SOLUTION FOR QUESTION 2: DELPHI

2.1.   CLASS UNIT

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;

          function GetName         : String;
          function GetGender       : Char;
          function GetQuestionnaires : Integer;
          procedure SetQuestionnaires (iQuestionnaires : Integer);
          function GetHours         : Real;
          procedure SetHours(rHours : Real);
   end;

implementation

uses SysUtils;

{ TStudent }

constructor TStudent.Create(sName: String; cGender: Char;
  iQuestionnaires: Integer; rHours: Real);
begin
   fName           := sName;
   fGender         := cGender;
   fQuestionnaires := iQuestionnaires;
   fHours          := rHours;
end;

function TStudent.calcAvg: Real;
begin
   Result := fQuestionnaires / fHours;
end;

function TStudent.toString: String;
begin
   Result := 'Student:' + fName + ' ('+fGender+')' + #13 +
             'Collected questionnaires: ' + IntToStr(fQuestionnaires) + #13 +
             'Total number of hours: ' + FloatToStr(fHours) + #13 +
             #13;
end;

function TStudent.GetName: String;
begin
   Result := fName;
end;
Copyright reserved                                                       Please turn over

### Page 11

Information Technology/P1                  11                     DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

function TStudent.GetGender: Char;
begin
   Result := fGender;
end;

function TStudent.GetQuestionnaires: Integer;
begin
   Result := fQuestionnaires;
end;

procedure TStudent.SetQuestionnaires(iQuestionnaires: Integer);
begin
   fQuestionnaires := iQuestionnaires;
end;

function TStudent.GetHours: Real;
begin
   Result := fHours;
end;

procedure TStudent.SetHours(rHours: Real);
begin
   fHours := rHours;
end;

end.

2.2.   MAIN FORM UNIT – QUESTION 2

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

### Page 12

Information Technology/P1               12                        DBE/Feb.–Mar. 2014
                                 NSC – Memorandum

implementation

{$R *.dfm}
{$R+}

procedure TfrmQ2.FormCreate(Sender: TObject);
var
  TFile             : TextFile;
  iCollectQ         : Integer;
  sName, sGender    : String;
  cGender           : Char;
  rHours            : Real;
begin
  IF NOT FileExists('DataQ2.txt') then
     begin
       MessageDlg('File does not exists.', mtInformation, [mbOK], 0);
       mnuOptionA.Visible := False;
       mnuOptionB.Visible := False;
       mnuOptionC.Visible := False;
       Exit;
     end;
  AssignFile(TFile, 'DataQ2.txt');
  Reset(TFile);
  iCounter := 0;
  while NOT EOF(TFile) Do
     begin
      Readln(TFile, sName);
      Readln(TFile, sGender);
      Readln(TFile, iCollectQ);
      Readln(TFile, rHours);
      cGender := sGender[1];
      Inc(iCounter, 1);
      arrData[iCounter] := TStudent.Create(sName, cGender, iCollectQ, rHours);
     end;
  CloseFile(TFile);
end;

procedure TfrmQ2.mnuOptionAClick(Sender: TObject);
var
    A : Integer;
begin              // Menu Option A
 redQ2.Lines.Clear;
 redQ2.Lines.Add('List of students' + #13);
 for A := 1 to iCounter do
    redQ2.Lines.Add(arrData[A].toString);
end;

procedure TfrmQ2.mnuOptionBClick(Sender: TObject);
var
    A                : Integer;
    rHighM, rHighF   : Real;
    sNameM, sNameF   : String;
begin              // Menu Option B
 redQ2.Lines.Clear;
 rHighM := 0;
 rHighF := 0;
 for A := 1 to iCounter do
  begin
      case arrData[A].GetGender of
         'M' : begin

Copyright reserved                                                    Please turn over

### Page 13

Information Technology/P1                  13                    DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

                    IF arrData[A].calcAvg > rHighM then
                      begin
                        rHighM := arrData[A].calcAvg;
                        sNameM := arrData[A].GetName;
                      end;
                 end;//m.
               'F' : begin
                    IF arrData[A].calcAvg > rHighF then
                      begin
                        rHighF := arrData[A].calcAvg;
                        sNameF := arrData[A].GetName;
                      end;
                 end;//if
      end;     //case
  end; //for
  redQ2.Lines.Add('Students with the highest average values:'+#13);
  redQ2.Lines.Add('Male: ' + sNameM + ' with an average of ' +
                         FloatToStrF(rHighM, ffFixed, 8,2));
  redQ2.Lines.Add(' ');
  redQ2.Lines.Add('Female: ' + sNameF + ' with an average of ' +
                         FloatToStrF(rHighF, ffFixed, 8,2));
end;

procedure TfrmQ2.mnuOptionCClick(Sender: TObject);
var
    bFound                : Boolean;
    A, iQuestionnaires : Integer;
    rHours                : Real;
    sName                 : String;
begin                // Menu Option C
  sName := InputBox('Question 2', 'Name of student', 'Eliana');
  iQuestionnaires := StrToInt(InputBox('Question 2', 'Number of completed
questionairs collected', '17'));
  rHours := StrToFloat(InputBox('Question 2', 'Number of hours', '1.5'));
  A := 1 ;
  bFound := False;
  while (A <= iCounter) AND NOT bFound do
   begin
       IF arrData[A].GetName = sName then
          begin
            bFound := True;
            arrData[A].SetQuestionnaires(arrData[A].GetQuestionnaires +
                                                        iQuestionnaires);
            arrData[A].SetHours(arrData[A].GetHours + rHours);
          end
        else
          inc(A, 1);
   end; //while
   IF NOT bFound then
      begin
        redQ2.Lines.Clear;
        redQ2.Lines.Add('The student is not on the list');
      end
     else
      mnuOptionA.Click;
end;

procedure TfrmQ2.mnuQuitClick(Sender: TObject);
  begin
     Application.Terminate;
  end;

end.
Copyright reserved                                                    Please turn over

### Page 14

Information Technology/P1                  14                    DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

ANNEXURE F: SOLUTION QUESTION 3: DELPHI (OOP)

3.1.   PLAYER CLASS UNIT

// An OOP solution for Question 3
unit uPlayer;
interface

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;

constructor TPlayer.Create(sGName, sDevice: String);
begin
     fGameName  := sGName;
     fDevice    := sDevice;
end;

function TPlayer.GetGameName: String;
begin
  Result := fGameName;
end;

function TPlayer.GetDevice: String;
begin
  result := fDevice;
end;

procedure TPlayer.SetGameName(sGName: String);
begin
  fGameName := sGName;
end;

procedure TPlayer.SetDevice(sDevice: String);
begin
   fDevice := sDevice;
end;

function TPlayer.toString: String;
begin
   Result := 'Player{' + 'Game = ' + fGameName + ', device =' + fDevice + '}';
end;

end.

Copyright reserved                                                   Please turn over

### Page 15

Information Technology/P1                  15                     DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

3.2.    MAIN FORM UNIT - QUESTION 3

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');

  arrGames      : array[1..20] of String;
  iGCounter     : Integer;

  arrPlayers : array[1..35] of TPlayer;

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

### Page 16

Information Technology/P1                16                        DBE/Feb.–Mar. 2014
                                  NSC – Memorandum

     arrPlayers[A] := TPlayer.Create(sGName, sDevice);
  end;
end;

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;

procedure processData(iGameNo:Integer;var iPC,iXbox,iPS3,iCount:Integer);
var
  A         : Integer;
  sGName : String;
begin
    iPC     := 0;
    iXbox := 0;
    iPS3    := 0;
    iCount := 0;
    sGName := arrGames[iGameNo];
    for A := 1 to length(arrPlayers) do
     begin
         IF UpperCase(sGName) = UpperCase(arrPlayers[A].GetGameName) then
           begin
              Inc(iCount, 1);
              IF UpperCase(arrPlayers[A].getDevice) = 'PC' then inc(iPC, 1);
              IF UpperCase(arrPlayers[A].getDevice) = 'PS3' then inc(iPS3, 1);
              IF UpperCase(arrPlayers[A].getDevice) = 'XBOX' then inc(iXbox, 1);
           end; //if.
     end; //for A.
end;

procedure TfrmQ3memo.mnuOptionAClick(Sender: TObject);
var
  sGName                                  : String;
  A, iGameNo, iPC, iXbox, iPS3, iCount    : Integer;
begin
    redQ3.Lines.Clear;
    redQ3.Lines.Add('List of games:');

Copyright reserved                                                     Please turn over

### Page 17

Information Technology/P1               17                       DBE/Feb.–Mar. 2014
                                 NSC – Memorandum
   redQ3.Lines.Add(' ');

   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;

procedure TfrmQ3memo.mnuQuitClick(Sender: TObject);
begin
   Application.Terminate;
end;

procedure TfrmQ3memo.FormCreate(Sender: TObject);
begin
  CreatePlayerObjects;
  CreateGamesArray;
end;

end.

Copyright reserved                                                   Please turn over

### Page 18

Information Technology/P1                     18                  DBE/Feb.–Mar. 2014
                                       NSC – Memorandum

ANNEXURE G: SOLUTION FOR QUESTION 3: DELPHI (Without OOP)

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');

   arrGames          : array[1..20] of String;
   iGCounter         : Integer;

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;

Copyright reserved                                                      Please turn over

### Page 19

Information Technology/P1                19                       DBE/Feb.–Mar. 2014
                                  NSC – Memorandum

      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;

procedure ProcessData(iGameNo:Integer; var iPC, iXbox, iPS3, iCount:Integer);
var
  sGName : String;
  A         : Integer;
begin
    iPC     := 0;
    iXbox := 0;
    iPS3    := 0;
    iCount := 0;
    sGName := arrGames[iGameNo];
    for A := 1 to length(arrData) do
     begin
           IF Pos(sGName, arrData[A]) > 0 then
              begin
               Inc(iCount, 1);
               IF pos('#PC', arrData[A]) > 0 then inc(iPC, 1);
               IF pos('#PS3', arrData[A]) > 0 then inc(iPS3, 1);
               IF pos('#Xbox', arrData[A]) > 0 then inc(iXbox, 1);
              end; //if
     end; //for A
end;

procedure TfrmQ3.mnuOptionAClick(Sender: TObject);
var
  sGName, sDevice                       : String;
  A,iGameNo, iPC, iXbox, iPS3, iCount : Integer;
begin
   CreateGamesArray;
   redQ3.Lines.Clear;
   redQ3.Lines.Add('List of Games');
   redQ3.Lines.Add(' ');
   for A := 1 to iGCounter do
       redQ3.Lines.Add(IntToStr(A) + '. ' + arrGames[A]);
   repeat
      iGameNo := StrToInt(InputBox('Question 3', 'Enter the number of a games from the
                                                                   list', '1'));
      IF NOT(iGameNo in [1..iGCounter]) then
          ShowMessage('Invalid input');
   until iGameNo in [1..iGCounter];

   sGName := arrGames[iGameNo];

   ProcessData(iGameNo, iPC, iXbox, iPS3, iCount);
   redQ3.Lines.Clear;

Copyright reserved                                                    Please turn over

### Page 20

Information Technology/P1               20                       DBE/Feb.–Mar. 2014
                                 NSC – Memorandum

   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;

procedure TfrmQ3.mnuQuitClick(Sender: TObject);
begin
  Application.Terminate;
end;

end.

Copyright reserved                                                   Please turn over

### Page 21

Information Technology/P1                  21                       DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

ANNEXURE H: SOLUTION FOR QUESTION 1: JAVA

//A solution for Question 1
   import java.io.*;
   import java.sql.*;
   import javax.swing.*;
   import java.util.Scanner;

       public class TestQuestion1
   {
       public static void main (String[] args) throws SQLException,IOException
       {
         Scanner sc = new Scanner(System.in);
       // OR BufferedReader inKb = new BufferedReader (new InputStreamReader
                                                                (System.in));

         Question1 DB = new Question1();
         System.out.println();

       char choice = ' ';
       do
       {
         System.out.println("\n\n        MENU");
         System.out.println();
         System.out.println("      Option A");
         System.out.println("      Option B");
         System.out.println("      Option C");
         System.out.println("      Option D");
         System.out.println("      Option E");
         System.out.println("      Option F");
         System.out.println("      Option G");
         System.out.println();
         System.out.println("      Q - QUIT");
        System.out.println(" ");
        System.out.print("       Your choice? ");
        choice = sc.nextLine().toUpperCase().charAt(0);
        // OR choice = inKb.readLine().toUpperCase().charAt(0);
        System.out.println(" ");
        String sql = "";
        switch(choice)
        {
//============================================================================
           case 'A':       // Question 1.1
           {
               sql = "SELECT * FROM tblRespondents ORDER BY QuestID DESC";
               DB.query(sql);
               break;
             }
//=============================================================================
           case 'B':       // Question 1.2
             {
                sql = "SELECT QuestID, DateSubmitted, StudentID FROM tblRespondents
                           WHERE DateSubmitted > #2013/08/07#";
                DB.query(sql);
                break;
            }
//=============================================================================

Copyright reserved                                                      Please turn over

### Page 22

Information Technology/P1                  22                        DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

                 case 'C': // Question 1.3
                 {
                   System.out.println("Enter the name or part of the name of a city:");
                   String sX = sc.nextLine();
                    // OR String sX = inKb.readLine();
                   sql = "SELECT City, NumMobileDevices, ConnectionType FROM
                      tblRespondents WHERE City LIKE '%" + sX + "%' AND
                      NumMobileDevices >= 2 AND InternetContract = TRUE";
                  DB.query(sql);
                  break;
              }
//=============================================================================
            case 'D':    // Question 1.4
            {
              sql = "SELECT City, FORMAT(AVG(NumMobileDevices), '0.00') AS
                   AvgMobilePerCity FROM tblRespondents GROUP BY City";
              DB.query(sql);
              break;
            }
//=============================================================================
            case 'E':    // Question 1.5
            {
              sql = "SELECT Name, Surname, YearOfStudy,COUNT(*) AS NumQuestionnaires
                   FROM tblRespondents, tblStudents WHERE tblRespondents.StudentID =
                   tblStudents.StudentID GROUP BY Name, Surname, YearOfStudy";
              DB.query(sql);
              break;
            }
//=============================================================================
            case 'F':    // Question 1.6
            {
              sql = "UPDATE tblRespondents,tblStudents SET NumMobileDevices =
                     NumMobileDevices + 1 WHERE tblRespondents.studentID =
                   tblStudents.studentID AND name = 'Kabelo' AND surname = 'Mkosi'";
              DB.query(sql);
              break;
            }
//=============================================================================
            case 'G':    // Question 1.7
            {
              sql = "DELETE FROM tblRespondents WHERE InternetContract = False AND
                         ConnectionType IS NOT NULL";
              DB.query(sql);
              break;
            }
         }
        }while (choice != 'Q');
        DB.disconnect();
        System.out.println("Done");
      }
   }

Copyright reserved                                                       Please turn over

### Page 23

Information Technology/P1                  23                      DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

ANNEXURE I: SOLUTION FOR QUESTION 2: JAVA

2.1.     OBJECT CLASS

//A solution for Question 2 - OOP

public class StudentMemo {

    private String name;
    private char gender;
    private int questionnaires;
    private double hours;

    public StudentMemo( String name, char gender, int questionnaires, double hours) {
          this.name = name;
          this.gender = gender;
          this.questionnaires = questionnaires;
          this.hours = hours;
    }

    public double calcAve() {
          return questionnaires / hours;
      }

  public String toString()    {
        return "Student: " + getName() + " (" + gender + ")\nCollected
questionnaires: " + getQuestionnaires() + "\nTotal number of hours: " + getHours() +
"\n";
    }

    public String getName() {
          return name;
      }

    public char getGender() {
          return gender;
      }

    public int getQuestionnaires() {
          return questionnaires;
      }

    public void setQuestionnaires(int questionnaires) {
          this.questionnaires = questionnaires;
      }

    public double getHours() {
          return hours;
      }

       public void setHours(double hours) {
           this.hours = hours;
       }

}

Copyright reserved                                                     Please turn over

### Page 24

Information Technology/P1                  24                       DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

2.2.   TEST/DRIVER CLASS - QUESTION 2

// Asolution for Question 2 - OOP
import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;

public class TestQuestion2_Memo {

public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
Scanner sf;
// OR BufferedReader bf;
//BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));

int counter = 0;
StudentMemo[] arrData = new StudentMemo[20];

// try {
      sf = new Scanner(new FileReader("DataQ2.txt"));

       // OR bf = new BufferedReader(new FileReader("DataQ2.txt"));
       // String name = bf.readLine();
       // while (name != null)
       while (sf.hasNext())
       {
           String name = sf.nextLine();
           char gender = sf.nextLine().charAt(0);
           // OR char gender = bf.readLine().charAt(0);
           int questionnaires = Integer.parseInt(sf.nextLine());
           // OR int questionnaires = Integer.parseInt(bf.readLine());
           double hours = Double.parseDouble(sf.nextLine());
           // OR double hours = Double.parseDouble( bf.readLine());
           arrData[counter] = new StudentMemo(name, gender, questionnaires, hours);
           counter++;
           // OR name = bf.readLine();
         }
       sf.close();
           /* Needed when using BufferedReader
                       bf.close();
           } catch (FileNotFoundException e) {
               System.out.println("File does not exist");
               System.exit(0);
           } catch (Exception f) {
               System.out.println(f);
           } */

          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?   ");

Copyright reserved                                                      Please turn over

### Page 25

Information Technology/P1                  25                          DBE/Feb.–Mar. 2014
                                    NSC – Memorandum

               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();

              System.out.println("Number of completed questionnaires collected: ");
              String collectedQ = sc.nextLine();
               // OR String collectedQ = kb.readLine();

              System.out.println("Number of hours: ");
              String newhours = sc.nextLine();
               // OR String newhours = kb.readLine();

              boolean found = false;
              int count = 0;
              while (found == false && count < counter) {
               if (arrData[count].getName().equalsIgnoreCase(name)) {
                 found = true;
                 int questionnaires = arrData[count].getQuestionnaires();
                 double hours = arrData[count].getHours();
                 arrData[count].setQuestionnaires(questionnaires +
                                             Integer.parseInt(collectedQ));
                 arrData[count].setHours(hours + Double.parseDouble(newhours));
              }

Copyright reserved                                                         Please turn over

### Page 26

Information Technology/P1                   26                         DBE/Feb.–Mar. 2014
                                     NSC – Memorandum

                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');
    }
}

Copyright reserved                                                         Please turn over

### Page 27

Information Technology/P1                   27                    DBE/Feb.–Mar. 2014
                                     NSC – Memorandum

ANNEXURE J: SOLUTION FOR QUESTION 3: JAVA (OOP)

3.1. PLAYER OBJECT CLASS:
//An OOP solution for Question 3
public class Player {
    private String game;
    private String device;

     public Player(String game, String device) {
         this.game = game;
         this.device = device;
     }

     public String getDevice() {
         return device;
     }

     public void setDevice(String device) {
         this.device = device;
     }

     public String getGameName() {
         return game;
     }

     public void setGameName(String game) {
         this.game = game;
     }

     public String toString() {
         return "Player{" + "game = " + game + ", device = " + device + "}";
     }
}

3.2. SURVEYSTATS OBJECT CLASS
//OOP solution for Question 3
   import java.io.BufferedReader;
   import java.io.IOException;
   import java.io.InputStreamReader;
   import java.text.DecimalFormat;
   import java.util.Scanner;

    public class SurveyStats {

      Scanner sc = new Scanner(System.in);
     // OR BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
       String[] arrGames = new String [20];
       int gamesCounter = 0;
       Player [] arrPlayers = new Player[35];

       public void populateArr(String [] arrData) {
          for (int cnt = 0; cnt < arrData.length; cnt++)
          {
             String[] arrItems = arrData[cnt].split("#");
             arrPlayers[cnt] = new Player(arrItems[0], arrItems[1]);
          }
       }

Copyright reserved                                                     Please turn over

### Page 28

Information Technology/P1                 28                        DBE/Feb.–Mar. 2014
                                   NSC – Memorandum

       public void createGamesArray()
       {
          String gameName = "";
          int b = 0;
          for (int cnt = 0; cnt < arrPlayers.length; cnt++)
          {
             gameName = arrPlayers[cnt].getGameName();
             boolean found = false;
             while (!(found) && (b < arrGames.length))
             {
                if ( gameName.equalsIgnoreCase(arrGames[b]))
                    found = true;
                else
                    b++;
             }
             if (!(found))
             {
                arrGames[gamesCounter] = gameName;
                gamesCounter++;
             }
             b = 0;
          }
          gamesCounter--;
       }

       public int getGamesCounter()
       {
          return gamesCounter;
       }

       public int displayMenu() throws IOException {
          System.out.println("List of games:\n==============");
          int cnt;
          for (cnt = 0; cnt <= gamesCounter; cnt++) {
               System.out.println((cnt + 1) + "\t" + arrGames[cnt]);
          }
          int gameNr = 0;
          do
          {
             try
             {
                System.out.print("\nEnter the number of a game from the list > ");
                gameNr = Integer.parseInt(sc.nextLine());
                // OR int gameNr = Integer.parseInt(kb.readLine());
             } catch (NumberFormatException E)
             {
                System.out.println("Invalid input");
             }
          }while (!((gameNr > 0) && (gameNr <= gamesCounter+1)));
          return gameNr;
       }

       public void getStats(int choice)
       {
          String gameOfChoice = arrGames[choice];
          int cntPS3 = 0;
          int cntXbox = 0;
          int cntPC = 0;
          double number = 0;

Copyright reserved                                                      Please turn over

### Page 29

Information Technology/P1                 29                        DBE/Feb.–Mar. 2014
                                   NSC – Memorandum

           for (int cnt = 0; cnt < arrPlayers.length; cnt++)   {
                    if (arrPlayers[cnt].getGameName().equals(gameOfChoice)) {
                       number++;
                       String device = arrPlayers[cnt].getDevice();
                       if (device.indexOf("PS3") >= 0) {
                          cntPS3++;
                       }
                       if (device.indexOf("Xbox") >= 0) {
                          cntXbox++;
                       }
                       if (device.indexOf("PC") >= 0) {
                          cntPC++;
                       }
                    }
                 }
         System.out.println(gameOfChoice + " was mentioned " + number + " 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", (cntPS3
       / number * 100), "%", (cntXbox / number * 100), "%", (cntPC / number * 100),
       "%");
         System.out.println(headings);
         System.out.println(outString);
         System.out.println();
         }
       }

3.3. TESTQUESTION3 DRIVER CLASS

//An OOP solution for Question 3
import java.io.*;
import java.util.Scanner;

public class TestQuestion3{
      public static void main(String[] args) throws IOException {
         Scanner sc = new Scanner(System.in);
         // OR BufferedReader bf = new BufferedReader(new
InputStreamReader(System.in));

         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"};

           SurveyStats obj = new SurveyStats();

           char cChoice = ' ';
           int gChoice = 0;

           obj.populateArr(arrData);
           obj.createGamesArray();

Copyright reserved                                                      Please turn over

### Page 30

Information Technology/P1                 30                       DBE/Feb.–Mar. 2014
                                   NSC – Memorandum

           int gamesCounter = obj.getGamesCounter();
           do {
              System.out.println("=============================");
              System.out.println("    MENU\n");
              System.out.println("Option A");
              System.out.println("");
              System.out.println("Q - QUIT");
              System.out.println("\nYour choice? ");
              cChoice = sc.nextLine().toUpperCase().charAt(0);
              // OR cChoice = kb.readLine().toUpperCase().charAt(0);
              switch (cChoice) {
                 case 'A':
                    gChoice = obj.displayMenu();
                    obj.getStats(gChoice-1);
                    break;
                 case 'Q':
                    System.out.println("Quit");
                    break;
              }
           } while (cChoice != 'Q');
       }
   }

Copyright reserved                                                     Please turn over

Text truncated here. Open the document page to read the rest.

## Related documents

- [Information Technology P2 Feb-March 2015 Memo Eng](https://www.hlayiso.com/library/grade-12-information-technology-2015-supplementary-exam-memorandum-paper-2-english/0b7ab643-dab4-4a87-95c0-6767340def68) — Information Technology · Memo · 2015 · Eng
- [IT P1 GR12 MEMO SEPT 2019 English](https://www.hlayiso.com/library/it-p1-gr12-memo-sept-2019-english/e1bbda31-02cd-4390-8960-747e62fdb1ee) — Information Technology · Memo · 2019 · Eng
- [INFT P1 GR12 SEPT2014 MEMO AFR](https://www.hlayiso.com/library/inft-p1-gr12-sept2014-memo-afr/4be11126-3cdb-4383-b442-678952a4e97e) — Information Technology · Memo · 2014 · Afr
- [Information Technology P1 Nov 2014 Memo Eng](https://www.hlayiso.com/library/information-technology-p1-nov-2014-memo-eng/5ce60bf6-fbc5-4741-8abb-86a179de07b7) — Information Technology · Memo · 2014 · Eng
- [Information Technology P1 Nov 2014 Memo Afr](https://www.hlayiso.com/library/information-technology-p1-nov-2014-memo-afr/f95a8905-970c-4975-bcc9-bb42cd12abbc) — Information Technology · Memo · 2014 · Afr
- [INFORMATION TECHNOLOGY P1 GR 12 QP SEPT2020 English](https://www.hlayiso.com/library/information-technology-p1-gr-12-qp-sept2020-english/54a79498-b880-4b85-a745-f97411d425cb) — Information Technology · QP · 2020 · Eng

## More from Grade 12 Information Technology

- [IT P2 QP GR12 SEPT 2024 AFR](https://www.hlayiso.com/library/it-p2-qp-gr12-sept-2024-afr/9016098b-e233-49f4-b1dc-f0838363c6af) — QP · 2024 · Afr
- [IT P2 QP GR12 SEPT 2024 English](https://www.hlayiso.com/library/it-p2-qp-gr12-sept-2024-english/83309154-2856-47f1-82cc-cc04c8ab38b1) — QP · 2024 · Eng
- [Information Technology P1 Nov 2024 Afr](https://www.hlayiso.com/library/information-technology-p1-nov-2024-afr/f4b19c44-77ce-482a-9f85-438813c25f87) — QP · 2024 · Afr
- [Information Technology P2 Nov 2024 Eng](https://www.hlayiso.com/library/information-technology-p2-nov-2024-eng/3afa20d1-1c0f-4969-8a56-d690e9b24d70) — QP · 2024 · Eng
- [Information Technology P1 May-June 2023 Eng](https://www.hlayiso.com/library/information-technology-p1-may-june-2023-eng/896eee2c-884c-4527-97e2-ed0759edd97d) — QP · 2023 · Eng
- [Information Technology P1 Nov 2023 Eng](https://www.hlayiso.com/library/information-technology-p1-nov-2023-eng/8ae9d306-1975-4759-ad2b-96483154bd10) — QP · 2023 · Eng

## Collection

- [Grade 12 past papers](https://www.hlayiso.com/grade-12/past-papers)

---

Hlayiso: free CAPS and IEB past papers, memos, notes and study guides for South African learners. When citing, link the page URL above, not a PDF or /api/ URL.
