INFORMATION TECHNOLOGY PAPER 1
GRADE 12
NATIONAL SENIOR CERTIFICATE EXAMINATIONS
MAY/JUNE 2019

INSTRUCTIONS AND INFORMATION

  1. This question paper is divided into FOUR sections. Candidates must answer ALL the questions in all FOUR sections.
  2. The duration of this examination is three hours. Because of the nature of this examination it is important to note that you will not be permitted to leave the examination room before the end of the examination session.
  3. This question paper is set with programming terms that are specific to the Delphi programming language.
  4. Make sure that you answer the questions according to the specifications that are given in each question. Marks will be awarded according to the set requirements.
  5. Answer only what is asked in each question. For example, if the question does not ask for data validation, then no marks will be awarded for data validation.
  6. Your programs must be coded in such a way that they will work with any data and not just the sample data supplied or any data extracts that appear in the question paper.
  7. Routines, such as search, sort and selection, must be developed from first principles. You may NOT use the built-in features of Delphi for any of these routines.
  8. All data structures must be defined by you, the programmer, unless the data structures are supplied.
  9. You must save your work regularly on the disk/CD/DVD/flash disk you have been given, or on the disk space allocated to you for this examination session.
  10. Make sure that your examination number appears as a comment in every program that you code, as well as on every event indicated.
  11. If required, print the programming code of all the programs/classes that you completed. You will be given half an hour printing time after the examination session.
  12. At the end of this examination session you must hand in a disk/CD/DVD/ flash disk with all your work saved on it OR you must make sure that all your work has been saved on the disk space allocated to you for this examination session. Ensure that all files can be read.
  13. The files that you need to complete this question paper have been given to you on the disk/CD/DVD/flash disk or on the disk space allocated to you. The files are provided in the form of password-protected executable files.
    NOTE: Candidates must use the file DataENGJun2019.exe.
    Do the following:
    • Double click on the password-protected executable file.
    • Click on the 'Extract' button.
    • Enter the following password: Plant2BGreen!
      Once extracted, the following list of files will be available in the folder DataENGJun2019:
      SUPPLIED FILES
      Question 1:
      Question1_P.dpr
      Question1_P.dproj
      Question1_P.res
      Question1_U.dfm
      Question1_U.pas

      Question 2:
      ConnectDB_U.dcu
      ConnectDB_U.pas
      NurseryDB.mdb
      NurseryDB_Backup.mdb
      Question2_P.dpr
      Question2_P.dproj
      Question2_P.res
      Question2_U.dfm
      Question2_U.pas

      Question 3:
      Logbook.txt
      Question3_P.dpr
      Question3_P.dproj
      Question3_P.res
      Question3_U.dfm
      Question3_U.pas
      star.png
      Trainee_U.pas

      Question 4:

      Question4_P.dpr
      Question4_P.dproj
      Question4_P.res
      Question4_U.dfm
      Question4_U.pas

SECTION A
QUESTION 1: GENERAL PROGRAMMING SKILLS
Do the following:

  • Open the incomplete program in the Question 1 folder.
  • Enter your examination number as a comment in the first line of the Question1_U.pas file.
  • Compile and execute the program. The user interface displays FOUR sections labelled QUESTION 1.1 to QUESTION 1.4. The program has no functionality currently.

Example of the graphical user interface (GUI):
1
Follow the instructions below to complete the code for EACH section of QUESTION 1, as described in QUESTION 1.1 to QUESTION 1.4.
1.1 Button [1.1 - Random number] Write code to do the following:

  • Generate a random number in the range 100–120 (inclusive).
  • Display the random number in the edtRandomNumber edit box. Example of output if the random number generated is 108: (4)
    2

1.2 Button [1.2 - Calculate minutes] A school dance has many learners participating. The organisers need to determine how long it will take to introduce all the participants. The time allocated to introduce each participant will depend on the total number of participants. The following criteria will be used:

Number of participants Number of minutes per participant
 Less than or equal to 20   2.5 minutes
 More than 20 and less than or equal to 50  2.3 minutes
  More than 50  2.0 minutes

The user must enter the number of participants in the edtParticipants edit box. Write code to do the following:

  • Extract the number of participants from the edtParticipants edit box.
  • Calculate the total number of minutes that will be required to introduce ALL the participants. Display the value in the edtMinutes edit box to TWO decimal places.
  • Round up the calculated number of minutes and display the result in the edtMinsRounded edit box.

Use the following test data:

Number of participants Minutes Minutes rounded
 13  32.50   33
 21  48.3  49
 50  115.00  115
 51  102.00  102

Example of output if the number of participants is 17:
3
(13)
1.3 Button [1.3 - Calculate factorial]
The factorial of a number is the product of multiplying all integers from 1 to the number, e.g.
The factorial of 4 = 1 x 2 x 3 x 4
= 24
The factorial of 6 = 1 x 2 x 3 x 4 x 5 x 6
= 720
The user must select a number from the spnNumber spin edit box. Write code to extract the number from the spnNumber spin edit box, calculate the factorial of the number and display the result in the edtFactorial edit box. Example of output if the number 5 is selected: (7)
4
1.4 Button [1.4 - Reverse words]
The characters in words in a sentence must be reversed for encryption purposes. The user must enter a sentence in the edtSentence edit box. Write code to do the following:

  • Extract the sentence from the edtSentence edit box.
  • Reverse the characters in EACH word in the sentence.
  • Display the result in the edtReverse edit box.

Example of input and output: (16)
5

  • Ensure that your examination number has been entered as a comment in the first line of the program file.
  • Save your program.
  • Print the code if required.

TOTAL SECTION A: 40

SECTION B
QUESTION 2: DATABASE PROGRAMMING
PJB Wholesale Garden Centre supplies plants to a number of nurseries. When a quotation for an order is given, the requested number of plants is checked for availability.
The database NurseryDB for PJB Wholesale Garden Centre contains two tables, namely tblPlants and tblOrders.
The data pages attached at the end of this question paper provide information on the design of the database and examples of the contents of the tables.
Do the following:

  • Open the incomplete project file called Question2_P.dpr in the Question 2 folder.
  • Add your examination number as a comment in the first line of the Question2_U.pas unit file.
  • Compile and execute the program. The program currently has no functionality.

NOTE: If the compiler shows an error message with regard to the given CurrencyString statement, remove the statement.
The following user interface is displayed:
6

  • Carry out the following instructions to complete the code for each section, as described in QUESTION 2.1 and QUESTION 2.2.
  • Use SQL statements to answer QUESTION 2.1 and Delphi code to answer QUESTION 2.2.

NOTE:

  • The 'Restore database' button is provided to restore the data contained in the database to the original content.
  • The content of the database is password protected. You will therefore not be able to gain access to the content of the database with Microsoft Access.
  • Code is provided to link the GUI components to the database.
  • Do NOT change any of the code provided.
  • TWO variables are declared as public variables, as described in the table below.
Variable Data type Description
tblPlants  TADOTable Refers to the table tblPlants
tblOrders TADOTable Refers to the table tblOrders

2.1 Tab sheet [Question 2.1 - SQL]
In this section you may use ONLY SQL statements to answer QUESTION 2.1.1 to QUESTION 2.1.5.
Code to execute the SQL statements and display the results of the queries is provided. The SQL statements are incomplete.
The following GUI is displayed:
7
Do the following:
Enter the SQL statements for QUESTION 2.1.1 to QUESTION 2.1.5 which is assigned to the variables sSQL1, sSQL2, sSQL3, sSQL4 and sSQL5 respectively.
2.1.1 Button [2.1.1 - List of roses]
Display all the details of the plants in the Rose category in the tblPlants table.
Example of output of the first five records: (3)
8
2.1.2 Button [2.1.2 - Pink roses and flowers]
Display the PlantCode, Category, Colour and SizeOfPot fields from the tblPlants table for all the plants in the Flower and Rose categories that have any type of pink colour.
Example of output of the last five records: (6)
9
2.1.3 Button [2.1.3 - Average price per category]
Use data from the tblPlants table to determine the average price for plants per category using AveragePrice as the new field name for the calculated field. The average price should be displayed in currency format.
Example of output: (5)
10
2.1.4 Button [2.1.4 - Display information for invoice number F2]
The invoice number will be the same for all items of a specific order.
Display the InvoiceNum, Description and NumberOrdered fields of all items ordered in the tblOrders table for invoice number F2.
Example of output: (5)
11
2.1.5 Button [2.1.5 - Update items delivered]
The number of items delivered differs sometimes from the number of items ordered in the table tblOrders.
Once an outstanding delivery has been made, the user must enter the item number (ItemNum) for the delivery that has been made. Write an SQL statement for variable sSQL5 to modify the NumDelivered field to contain the same value as the NumberOrdered field.
NOTE: Code is provided to request the user to enter the item number.
Example of output for item number 6 before the record was modified:
12
Example of output for item number 6 after the record had been modified: (4)
13
2.2 Tab sheet [Question 2.2 - Delphi code]
Use only programming code in this section to answer QUESTION 2.2.1 to QUESTION 2.2.2.
NO marks will be awarded for SQL statements in QUESTION 2.2.
The GUI for QUESTION 2.2 is shown below.
14
NOTE: The variables iNumOrdered and sPlantCode are provided as global variables. The content of these variables must be used in QUESTION 2.2.1 to check the availability of stock and in QUESTION 2.2.2 to place the order.
2.2.1 Button [2.2.1 - Check stock]
The stock available must be checked before an order can be placed.
The user must do the following:

  • Select a category from the Category combo box.

Code is provided to populate the combo box (cmbPlantCode) containing the plant code associated with the selected category.

  • Select a plant code from the cmbPlantCode combo box.
  • Enter the number of plants to be ordered in the provided edit box.

Code is provided to:

  • Extract the plant code selected from the cmbPlantCode combo box
  • Extract the number of plants entered from the edtNumPlants edit box

Write code to determine whether or not there is enough stock available.

  • If there is enough stock, display the plant code, colour, number of plants ordered and the price of the selected item in the output area redDisplay and enable the btnQ2_2_2 button.
  • If there is NOT enough stock available:
    • Display a message showing the number of plants in stock.
    • Ask the user whether he or she wants to continue to place the order for the available stock.
    • If the user wants to place the order:
      • Display the plant code, colour, number of plants ordered and the price of the selected item in the redDisplay output area.
      • Enable the btnQ2_2_2 button.
    • If the user does NOT want to place the order:
      • Display the message 'Order cancelled' in the redDisplay output area.
      • Disable the btnQ2_2_2 button.

Example of output if a request for 125 plants with code DIP002#M from the Creeper category was entered:
15
Example of output if a request for 225 plants with code DIP002#M from the Creeper category was entered with only 183 plants with this code being available:
16
Example of output if a request for 225 plants with code DIP002#M from the Creeper category was entered and the user does NOT want to place the order: (11)
17
2.2.2 Button [2.2.2 - Place an order]
An order must be placed in the tblOrders table using the following information:

  • The invoice number for this order in the tblOrders table must be F2.
  • The plant code and number of plants ordered must be obtained from the two global variables, which contain information that was specified in QUESTION 2.2.1.
  • The NumberDelivered field must be set to 0 since the delivery has not been made yet.

Example of output when placing an order for 125 plants with plant code DIP002#M: (6)
18

  • Ensure that your examination number has been entered as a comment in the first line of the program file.
  • Save your program.
  • Print the code if required.

TOTAL SECTION B: 40

SECTION C
QUESTION 3: OBJECT-ORIENTATED PROGRAMMING
Star Nursery invites learners from the local schools to a voluntary training programme as part of a community initiative. Learners who are used as trainees must attend training sessions to enable them to assist customers with enquiries and with the sale of plants.
Do the following:

  • Open the incomplete program in the Question 3 folder.
  • Open the incomplete object class Trainee_U.pas.
  • Enter your examination number as a comment in the first line of both the Question3_U.pas file and the Trainee_U.pas file.
  • Compile and execute the program. The program has no functionality currently.

Example of graphical user interface (GUI) that will be displayed:
19
The program will use the number of hours of the training and the value of the sales made to determine whether or not the trainee qualifies for a bonus.
Complete the code as specified in QUESTION 3.1 for the Trainee_U object class and QUESTION 3.2 for the Question3_U form class.
3.1 The incomplete object class (TTrainee) provided contains code for the following:

  • Declarations of four attributes that describe a Trainee object
  • A constructor Create method
  • An incomplete toString method
  • Two accessor methods: getName and getTraineeID

The attributes for the Trainee object have been declared as follows:

Names of attributes Description
fTraineeID  Unique number to identify the trainee
fName  Name and surname of the trainee 
fHours  Number of hours of training the trainee attended
fSales  Amount of the sales the trainee made 

3.1.1 The number of hours of training attended by the trainee and the amount of the sales made can be increased.

  1. Write code for a method called updateHours that receives a value as a parameter. Increase the hours attribute using the received parameter value. (4)
  2. Write code for a method called updateSales that receives a value as a parameter. Increase the sales attribute using the received parameter value. (2)

3.1.2 Write code for a method called qualifiesForBonus. The method must return a Boolean value TRUE if the trainee qualifies for a bonus or FALSE if the trainee does not qualify for a bonus.
A trainee qualifies for a bonus if the following conditions are met:

  • At least 15 hours of training was attended.
  • The amount of the sales is at least R 1 200.00. (5)

Related Items

3.1.3 Write code to complete the provided toString method to return a string in the following format:

<name and surname of the trainee> (<the trainee ID>)
attended <number of hours of training attended> hours
of training and sold plants to the value of <value of the plants
sold formatted to currency and two decimals>. 

Example of output when the toString method is called: (4)
20
3.2 The incomplete unit Question3_U has been provided which contains code for the object class to be accessible. An object variable called objTrainee has been declared.
A text file called Logbook.txt contains the log entries of all the training and sales activities of the trainees.
Each log entry contains information of a trainee in the following format:

<trainee ID>;<character T or S indicating training or a
sale that was made>#<numerical value indicating the
number of hours of training or the value of the sale that
was made> 

Example of the first four entries in the text file:

12;T#0.98
15;S#182.00
13;S#118.00
10;T#1.96 

The first two lines of text can be interpreted as follows:

  • 12;T#0.98 – Trainee with ID number 12 attended 0.98 hours of training
  • 15;S#182.00 – Trainee with ID number 15 made a sale to the value of R 182.00

Follow the instructions below to code the solution:
3.2.1 Button [3.2.1 - Click to continue]
The user must select the name of a trainee from the cmbTrainee combo box. Code is provided to do the following:

  • Extract the name from the combo box.
  • Assign an ID to the selected trainee using the variables sName and iTraineeID.

Write code to do the following:

  • Use the provided variables (sName and iTraineeID) and instantiate the objTrainee object.
  • Set the btnQ3_2_2 button to be visible. (4)

Example of the GUI if Kody Shaw is selected as the trainee and the 'Click to continue' button is clicked.
21
3.2.2 Button [3.2.2 – Process logbook data]
Write code to do the following:

  • Check whether or not the Logbook.txt text file exists. If the file does NOT exist, display a suitable message and close the program.
  • If the text file exists, search in each line of text for the selected trainee's ID.

If the trainee's ID is found, do the following:

  • Extract the entry type (T or S) and the value indicating the number of hours of training or the amount of the sale from the line of text.
  • Use the updateHours or updateSales method to update the trainee's hours or sales amount based on the type of entry (T or S).

Once all the data from the text file has been processed, do the following:

  • Clear the output area.
  • Display the information of the trainee in the output area using the toString method.
  • Set the btnQ3_2_3 button to be visible.

If the trainee's ID number could NOT be found in the text file, display the message 'The trainee is not registered.' in the output area.
Example of output if trainee Kody Shaw is selected and the logbook data is processed:
22
Example of output if trainee Lindiwe Dlamini is selected and the logbook data is processed: (18)
23
3.2.3 Button [3.2.3 - Qualifies for a bonus?]
Write code to do the following:

  • Determine if the trainee qualifies for a bonus using the qualifiesForBonus method.
  • Display a suitable message in the output area indicating whether or not the trainee qualifies for a bonus.

Example of output for trainee Kody Shaw:

Kody Shaw (10) attended 65.66 hours of training and
sold plants to the value of R 1 405.00.
The trainee qualifies for a bonus. 

Example of output for trainee Tyrone Kemsley:

Tyrone Kemsley (12) attended 65.66 hours of training
and sold plants to the value of R 1 078.00.
The trainee does NOT qualify for a bonus. (3)
  • Ensure that your examination number has been entered as a comment in the first line of the object class and the form class.
  • Save all files.
  • Print the code of both the object class and the form class if required.

TOTAL SECTION C: 40

SECTION D
QUESTION 4: PROBLEM-SOLVING PROGRAMMING
SCENARIO
The trees at the nursery are categorised using the types Citrus, Deciduous, Nut and Tropical.
Do the following:

  • Open the incomplete program in the Question 4 folder.
  • Enter your examination number as a comment in the first line of the Question4_U.pas file.
  • Compile and execute the program. The program has no functionality currently.

The GUI shown below is displayed.
24
The program contains code of the following for the declaration:

  • An array named arrTypes that contains the four types of trees at the nursery:
    arrTypes: array [1..4] of String = (
    'Citrus',
    'Deciduous',
    'Nuts',
    'Tropical');
  • A one-dimensional array named arrList that contains the list of 24 trees that are available at the nursery.

The format of the code in the array that represents each tree is as follows:
<tree name>#<first letter of tree type>

arrList: array[1..24] of String = (
'Orange#C','Hazelnut#N','Apple#D',
'Banana#T','Pecan#N','Pear#D',
'Lemon#C','Papaya#T','Kiwi#T',
'Apricot#D','Grapefruit#C','Walnut#N',
'Lime#C','Mango#T','Peach#D',
'Cashew#N','Almond#N','Tangerine#C',
'Avocado#T','Cherry#D','Plum#D',
'Macadamia#N','Kumquat#C','Guava#T');

The first two entries in arrList array can be explained as follows:
Orange#C means the tree name is Orange and the tree type is Citrus.
Hazelnut#N means the tree name is Hazelnut and the tree type is Nuts.

  • A two-dimensional array called arrTrees and two integer variables that contains the number of rows and columns of the arrTrees array:
    arrTrees: array [1..4, 1..6] of String;
    iTypes: integer = 4;
    iNum: integer = 6;

NOTE:

  • Do NOT change the code provided.
  • The use of good programming techniques and modular design must be applied in your solution.

Complete the code for EACH section of QUESTION 4, as described in QUESTION 4.1 to QUESTION 4.3 below.
4.1 Button [4.1 - Separate by type]
The data in the arrList array must be stored in the two-dimensional array arrTrees by row according to the types of trees, e.g. the data of the citrus trees must be stored in row 1, the deciduous trees in row 2, the nut trees in row 3 and the tropical trees in row 4.
Use the arrTypes array to determine the row value where the data of the tree must be stored in the arrTrees array, e.g. if the data string is 'Orange#C', then the tree is of type 'Citrus' and the data string 'Orange#C' must be stored in row 1. If the data string is 'Hazelnut#N', then the tree is of type 'Nuts' and the data string must be stored in row 3, and so on.
Write code to do the following:

  • Store the data of each tree in the arrList array in the correct position in the two-dimensional array arrTrees.
  • Enable buttons btnQ4_2 and btnQ4_3.(11)

4.2 Button [4.2 - Display]
Write code to display the types of trees contained in the arrTypes array and the trees corresponding with the types of trees from the arrTrees array.
Example of output: (7)
25
4.3 Button [4.3 - Sort alphabetically]
The trees in the arrTrees array must be sorted alphabetically as per tree type, e.g. citrus trees will appear as follows in row 1 of the arrTrees array:
Grapefruit Kumquat Lemon Lime Orange Tangerine
Write code to do the following:

  • Delete the last two characters of each element in the arrTrees array.
  • Sort the arrTrees array alphabetical per tree type.
  • Execute the code in the button btnQ4_2 to display the list of trees after it has been sorted.

Example of output: (12)
26

  • Ensure that your examination number has been entered as a comment in the first line of the program file.
  • Save your program.
  • Print the code if required.

TOTAL SECTION D: 30
GRAND TOTAL: 150

INFORMATION TECHNOLOGY
DATABASE INFORMATION FOR QUESTION 2:
The design of the database tables is as follows:
Table: tblPlants
This table contains a price list of all the stock in PJB Wholesale Garden Centre.

Field name Data type Description 
PlantCode  Text (13)  A unique code assigned to each plant item 
Description  Text (35) The description of each plant item
Category Text (12) Category of the plant item
SizeOfPot Text (4)  The pot size of the plant indicated with S, M, L, XL, XXL and XXXL 
Colour  Text (20)  Colour of the flowers 
Price  Currency Selling price of the plant
InStock Integer Number of plants in stock 

Example of data of the first ten records:
27
Table: tblOrders
This table contains the records of orders that were placed.

Field name Data type Description
ItemNum AutoNumber A unique number assigned to an item in an order
InvoiceNum Text (3) Every order receives an invoice number. An order may contain multiple items
PlantCode Text (13)  The code of the plant ordered – foreign key 
NumberOrdered Integer  Number of plants of a specific item ordered 
NumberDelivered  Integer  Number of plants of a specific item delivered 

Example of data of the first ten records:
28
The following one-to-many relationship with referential integrity exists between the two tables in the database:
29

Last modified on Monday, 27 September 2021 13:50