INFORMATION TECHNOLOGY PAPER 1
GRADE 12
NOVEMBER 2020
NATIONAL SENIOR CERTIFICATE

INSTRUCTIONS AND INFORMATION

  1. This question paper is divided into FOUR sections. Candidates must answer ALL the questions in each of the 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 declared 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 DataENGJun2020.exe.
Do the following:

  • Double click on the password-protected executable file:
    DataENGJun2020.exe.
  • Click on the 'Extract' button.
  • Enter the following password: Plant2BGreen!

Once extracted, the following list of files will be available in the folder DataENGJun2020:
SUPPLIED FILES:
Question1:

Question1_P.dpr
Question1_P.dproj
Question1_P.res
Question1_U.dfm
Question1_U.pas

Question2:
ConnectDB_U.dcu
ConnectDB_U.pas
EmployeesDB.mdb
Question2_P.dpr
Question2_P.dproj
Question2_P.res
Question2_U.dfm
Question2_U.pas

Question3:
Question3_P.dpr
Question3_P.dproj
Question3_P.res
Question3_U.dfm
Question3_U.pas
Transaction_U.pas

Question4
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 project file called Question1_P.dpr 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 different sections named Question 1.1 to Question 1.4. The program has no functionality currently.

Example of the graphical user interface (GUI):
1
Complete the code for EACH section of QUESTION 1, as described in QUESTION 1.1 to QUESTION 1.4 that follow.

1.1 Button [1.1 - Colours]
The combo box cmbQ1_1 contains the items 'Red' and 'Green' currently.
Write code to change the content of the combo box cmbQ1_1 as follows when the btnQ1_1 button is clicked:

  • The font size of the text must be 12 pt.
  • 'Blue' must appear as a third option on the list of items.
  • The item ('Green') must be displayed as the default option.

Example of the appearance of the combo box when the btnQ1_1 button is clicked: (4)
2
1.2 Button [1.2 - Kite]
The formula to calculate the area of a kite is as follows:
area =length of diagonal one x length of diagonal two
                                            2
Example of calculation for a kite with a value of 20 for diagonal one (A) and 12 for diagonal two (B):
area =length of diagonal one(A) x length of diagonal two(B)
                                            2
=20 x 12
       2
=240
   2
=120
3
Code has been provided to allow the user to enter the values for diagonal one (A) and diagonal two (B) using input dialog boxes. These values are stored in variables iDiagA and iDiagB respectively.
Write code to do the following:

  • Declare a suitable numeric variable to store the area of the kite.
  • Test whether the value of diagonal one (A) is greater than the value of diagonal two (B) or not.

If the value of diagonal one (A) is greater than the value of diagonal two (B), use the provided formula to calculate the area of the kite. Display the area on label lblQ1_2 formatted to ONE decimal place.
If the value of diagonal one (A) is NOT greater than the value of diagonal two (B), display a suitable message that briefly states that the value of diagonal one (A) must be greater than the value of diagonal two (B).
Example of output if the value of diagonal one (A) is 27 cm and the value of diagonal two (B) is 13 cm: (8)
4
1.3 Button [1.3 - Binary number] The conversion of an integer number into a binary number is done by repetitive division by 2 until the final answer of the division is equal to zero (0). The integer remainder of each division operation is combined into a string of digits (zeros and ones) starting with the last integer remainder up to the first integer remainder. The string of remainder digits represents the binary value of the original integer value.
The example below illustrates how the integer value of 19 is converted to a binary number:

Integer division by 2 Remainder
19 ÷ 2 = 9    1
9 ÷ 2 = 4   1
4 ÷ 2 = 2   0
2 ÷ 2 = 1   0
1 ÷ 2 = 0   1
Binary number: 100112

Concatenate the integer remainder from the last remainder up to the first remainder to construct the binary number that represents the integer value.

Write code to do the following:

  • Retrieve the integer number that was entered by the user in the edtQ1_3 edit box as a number value using the variable iNumber.
  • Initialise the string variable sBinary to store the binary value that will be constructed.
  • Convert the integer number to binary using the following algorithm:
    Repeat until the number value is equal to zero:
    • Determine the remainder of the number value divided by 2 using the variable called iRemainder.
    • Join (Append) the remainder to the left of the content of the string variable.
    • Divide the number value by 2 and save the answer in the number value variable (replacing the previous number value).
  • Use the label lblQ1_3 to display the content of the string variable sBinary.

Example of output if an integer value of 19 was entered:
5
Example of output if an integer value of 45 was entered: (11)
6
1.4 Button [1.4 - Word game]
A word game needs to be developed where each character in a word carries a specific number of points. Points are allocated as follows:

Characters Value in points
Vowels (A, E, I, O, U) 3 points 
Alphabetical characters that are not vowels 2 points 
Any other non-alphabetical character, such as an apostrophe or a hyphen 1 point 

The player must enter a single word in the edit box edtQ1_4. When the btnQ1_4 button is clicked, the program must calculate and display the total value of the word in terms of points. If more than one word is entered, the player is disqualified.
Write code to do the following:

  • Retrieve the word that was entered in the edit box edtQ1_4 and convert the text to upper case.
  • Test for the presence of a space in the text which indicates that more than one word was entered:
    • If a space is identified, display a suitable message indicating that the player has been disqualified. Clear the edtQ1_4 edit box and set the focus on the edit box.
    • If a space is not identified, calculate the total value of the word based on the number of points each character carries. Display the total value of the word in the provided rich edit component.

Example of output if the word Win was entered:
7
Example of output if the word non-subscriber was entered:
8
Example of output if the words Team one were entered:
9
(17)

  • 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

The database EmployeesDB contains the information of the employees of an import and export company. The database contains two tables called tblEmployees and tblHourLogs.
The data pages attached at the end of this question paper provide information on the design of the database and the content of the tables. Do the following:

  • Open the incomplete project file called Question2_P.dpr in the Question 2 folder.
  • Enter your examination number as a comment in the first line of the Question2_U.pas unit file.
  • Compile and execute the program. The program has no functionality currently.
  • The first four lines of data of each of the tables are displayed on the tab sheet Question 2.2 - Delphi code, as shown below.
    10
  • Follow the instructions below to complete the code for EACH section, as described in QUESTION 2.1 and QUESTION 2.2 that follow.
  • 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, in other words you will not be able to gain access to the content of the database using 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 global variables, as described in the table below.
Variable Data type Description
 tblEmployees TADOTable Refers to the table tblEmployees
tblHourLogs   TADOTable Refers to the table tblHourLogs 

2.1 Tab sheet [Question 2.1 - SQL]
Example of the graphical user interface (GUI) for QUESTION 2.1:
11
NOTE:

  • Use ONLY SQL statements to answer QUESTION 2.1.1 to QUESTION 2.1.5.
  • Code is provided to execute the SQL statements and display the results of the queries. The SQL statements assigned to the variables sSQL1, sSQL2, sSQL3, sSQL4 and sSQL5 are incomplete.

Complete the SQL statements to perform the tasks described in QUESTION 2.1.1 to QUESTION 2.1.5 that follow.
2.1.1 Button [2.1.1 - List of employees]
Display ALL the information on employees from the tblEmployees table, firstly sorted in ascending order according to the JobTitle field and secondly according to the HourlyWage field in descending order.

Example of output of the first four records: (4)
12.png
2.1.2 Button [2.1.2 - Engineers]
Display the EmployeeID, LastName and FirstName fields of employees whose job title contains the word 'Engineer'.
Example of output: (4)
13
2.1.3 Button [2.1.3 - Job titles]
Display a list of all the different job titles at the company. Each job title must be displayed ONCE only.
Example of output: (3)
14
2.1.4 Button [2.1.4 - Remove records]
A number of records with incorrect data on the hours worked have been captured in the tblHourLogs table.
Remove all the records in the tblHourLogs table where the HoursWorked is recorded as 99.
Code has been provided to display a message that indicates that the content of the database has been changed. (2)
2.1.5 Button [2.1.5 - Overtime]
Employees are paid overtime for each hour exceeding 8 hours per day. An employee's overtime payment is double his regular hourly wage.
Calculate and display the total amount each employee has been paid for overtime hours worked, formatted as currency. Display the amount using the field name OvertimeAmt. Display only the LastName and the calculated OvertimeAmt as output.
Example of output: (9)
15
2.2 Tab sheet [Question 2.2 - Delphi code]
NOTE:

  • Use ONLY Delphi programming code to answer QUESTION 2.2.1 and QUESTION 2.2.2.
  • NO marks will be awarded for SQL statements in QUESTION 2.2.

Example of the graphical user interface (GUI) for QUESTION 2.2:
16
2.2.1 Button [2.2.1 - Employees with first aid]
Write code to do the following:

  • Display the employee ID, last name and job title of ALL employees who have completed first aid training in the rich edit component redQ2.
  • Count the number of employees who completed first aid training and display the result below the employee details, as shown in the example below.

NOTE: Code to display the column headings has been provided.
Example of output: (7)
17
2.2.2 Button [2.2.2 - Add new employee]
Write code to add a new record to the tblEmployees table. The data for the employee is as follows:
Employee ID: EMP986
First name: Robert
Last name: Laubscher
Hourly wage: 195.00
Job title: Marine Engineer
First aid training: True
Example of the last few records in the tblEmployees table which shows that the record has been added to the table successfully:(6)
18
2.2.3 Button [2.2.3 - Update hours worked]
The administrator is able to change the logged number of hours for a record in the tblHourLogs table. The user must select a record in the DBGrid dbgHourLogs and enter the value in the edit box to replace the current number of hours worked.
Write code to update the HoursWorked field of the selected record to the value obtained from the edit box.
Example of the content of the record if the LogID 758 was selected and the value of 11 was entered for HoursWorked:
19
Example of the content of the record if LogID 774 was selected and the value of 8 was entered for HoursWorked: (5)
20

  • 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

An import-export company rent out containers to customers who use it to store goods for a specific period of time. Transactions are created between the company and the customers to keep track of the containers that have been rented out.
Do the following:

  • Open the incomplete program in the Question 3 folder.
  • Open the incomplete object class Transaction_U.pas.
  • Enter your examination number as a comment in the first line of both the Question3_U.pas file and the Transaction _U.pas file.
  • Compile and execute the program. The program has no functionality currently.
    Example of the graphical user interface (GUI):
    21
  • Complete the code as specified in QUESTION 3.1 for the Transaction_U object class and QUESTION 3.2 for the Question3_U form class.

3.1 The incomplete object class (TTransaction) provided contains four attributes and an incomplete toString method that defines a Transaction object.
The attributes for the Transaction object have been declared as follows:

Names of attributes Description
fCustomerID The South African identification number of a customer who is requesting to rent a container 
fContainerSize 

A character that indicates the size of the container:

  • S = Small
  • M = Medium
  • L = Large 
fStoragePeriod  Indicates the number of months that the container will be made available to the customer
fAmountPaid  The amount that the customer has already paid to use the container 

NOTE: You are not allowed to add any additional attributes or user-defined methods unless explicitly stated in the question.
3.1.1 Write code for a constructor method that will receive the customer ID, the container size and the storage period in months as parameter values. Assign these values to the respective attributes. Set the fAmountPaid attribute to the value of zero. (4)
3.1.2 Write code for an accessor method called getAmountPaid for the fAmountPaid attribute. (2)
3.1.3 Write code for a method called updateAmountPaid that will receive a value as a parameter and add the received value to the fAmountPaid attribute. (3)
3.1.4 Write code for a method called calculateCost that will use the Transaction object's attributes to calculate and return the cost for hiring the container.
The monthly cost of the container will depend on the size of the container, as indicated in the table below.

Container size Amount per month
S R1000.00 
M R1750.00 
L R2500.00 

The total cost of hiring the container is calculated as follows:

  • The monthly cost of the container is multiplied by the storage period in months.
  • A discount of 10% of the total cost is applied for every six months of the storage period, up to a maximum of 50%.

Example 1:

Container size:
Storage period (months):
Discount (%):  0% 
Cost:  R5250.00


Example 2:

Container size: S
Storage period (months): 6
Discount (%):  10% 
Cost:  R5400.00


Example 3:

Container size:
Storage period (months): 25 
Discount (%):  40%
Cost:  R37500.00


Example 4:

Container size: S
Storage period (months): 72
Discount (%):  50%
Cost:  R36000.00

(11)
3.1.5 An incomplete toString method has been supplied.
Write code to complete the toString method to return the attributes of the Transaction object in the following format:
Customer ID: <fCustomerID>
Container size: <fContainerSize>
Storage period (months): <fStoragePeriod>
Amount paid: <fAmountPaid>

Example:
Customer ID: 7203075021082
Container size: M
Storage period (months): 7
Amount paid: R0.00 (3)
3.2 An incomplete unit Question3_U has been provided and contains code for the object class to be accessible. A global TTransaction variable called objTransaction has been provided.
Do the following to complete the code for QUESTION 3.2.1 to QUESTION 3.2.3 in the main form unit:
3.2.1 Button [3.2.1 - Instantiate object]
Write code to do the following:

  • Extract the customer's ID from edtQ3_2_1, the first letter of the container size selected in lstQ3_2_1 and the storage period in months from sedQ3_2_1.
  • Instantiate a Transaction object using the values extracted from the user interface.
  • Disable the btnQ3_2_1 button.

NOTE: The provided code for the [Reset] button will remove the Transaction object from the memory and enable btnQ3_2_1 so that a new Transaction object can be instantiated. (7)
3.2.2

  1. Button [3.2.2 (a) - Display amount due]
    Write code to do the following:
    • Use the relevant method to calculate the amount due for hiring a container.
    • Display the amount due on the panel pnlQ3_2_2 in the following format:
      Amount due: <amount due>
      Example of output with the default values provided are selected, with no amount paid yet:
      22
      Example of output if the customer selected a small container size for a storage period of 3 months, with no amount paid yet: (3)
      23
  2. Button [3.2.2 (b) - Process payment]
    The customer needs to enter an amount to be paid in the provided edit box edtQ3_2_2.
    Write code to do the following:
    • Extract the amount that was entered in box edtQ3_2_2.
    • Use the appropriate method to update the attribute of the amount paid with the amount extracted from edtQ3_2_2.
    • Use the appropriate methods to calculate the updated amount due.
    • Display the updated amount due on the panel pnlQ3_2_2.
      Example of output if the customer selected a small container size for a storage period of 3 months, with an amount of R1 200 paid: (5)
      24

3.2.3 Button [3.2.3 - View details]
The customer must be able to view the details of the Transaction object. Code to clear the rich edit component has been provided.
Write code to display the attributes of the Transaction object in the provided rich edit by using the toString method.
Example of output with the default value selected and no amount paid yet:
25
Example of output if the customer selected a small container size for a storage period of 3 months, with an amount of R1 200 paid: (2)
26

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

TOTAL SECTION C: 40

SECTION D
QUESTION 4: PROBLEM-SOLVING PROGRAMMING

SCENARIO Tons of cargo are loaded into containers and stored in the harbour for shipment.
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.
    Example of the graphical user interface (GUI):
    27
  • Read the information below and complete the code for the tasks described in QUESTION 4.1 and QUESTION 4.2 that follow.
    The program contains the code shown below for the declaration of an array called arrContainers.
    arrContainers: array [1..50] of real;
    arrContainers is declared with a maximum size of 50 elements to store random real numbers that represent the different weights of each container in tons.
    NOTE: Code is provided to activate, deactivate and clear certain components for each event.

4.1 Write code as described in QUESTION 4.1.1 and QUESTION 4.1.2 to generate and display the weight of harbour containers.
4.1.1 Button [4.1.1 - Create harbour containers]
Write code to generate fifty (50) random real values in the range from 1 to 99 (both included) and rounded to ONE decimal place, and assign the values to the one-dimensional array called arrContainers.
NOTE: Use the provided array arrTempContainers if your attempt to populate the arrContainers array with random values was unsuccessful. (4)
4.1.2 Button [4.1.2 - Display harbour containers]
Write code to display the weight of the containers from the arrContainers array in the rich edit redQ4_1 arranged in 5 rows and 10 columns as shown in the example below.
Example of possible output:
28
NOTE: The values shown in the example will differ from your program's output, as the values are randomly generated every time the [4.1.1 - Create harbour containers] button is clicked. (8)
4.2 Button [4.2 - Containers loaded to be shipped]
A ship in the harbour must be loaded with containers from the one-dimensional array arrContainers. The total weight loaded onto the ship must be as close as possible, but not exceed, the maximum value of 200 tons.
Containers must be loaded row by row from the arrContainers array until the maximum weight is reached. If adding the weight of a specific container to the total weight causes the total weight to exceed the maximum weight of 200 tons, that specific container must not be loaded onto the ship. The program must search row by row through the remaining containers to find another container with a lower weight that can still be loaded onto the ship without exceeding the maximum weight.
The number of containers loaded onto the ship will depend on the random data generated in the arrContainers array.
Example of output for the random values generated in QUESTION 4.1.1.
29
Explanation:
The weight of the first five containers in row 1 adds up to a total value of 173.5 tons. Adding the weight of each of the next three containers (41.9, 97, and 49.3 respectively) will cause the allowed maximum weight to be exceeded, and are therefore not loaded. The next suitable container to be loaded will be the container with the weight of 15.8 tons and thereafter the container with the weight of 1.4 tons. The total weight of the containers to be loaded adds up 190.7 tons – the closest total to the value of 200 tons. No more containers can be loaded.
Write code to do the following:

  • Display the weight of the containers loaded onto the ship in the rich edit component called redQ4_2.
  • Write the weight of the containers loaded onto the ship to a new text file called Tons.txt.
  • Terminate the process of loading the containers onto the ship as soon as the maximum possible weight is loaded onto the ship.
  • Display the total weight loaded onto the ship on the panel pnlQ4.

Example of possible output:
30
Output for a different set of data generated: (18)
31

  • 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 P1
DATABASE INFORMATION FOR QUESTION 2:

The design of the database tables is as follows: Table: tblEmployees This table contains the details of the staff working at the import-export company.

Field name Data type Description
EmployeeID Text (8)  A unique ID that identifies an employee
FirstName  Text (40) The first name of the employee 
LastName Text (40) The last name of the employee
HourlyWage Currency  The amount the employee is paid per hour
JobTitle  Text (80)  The title of the employee's position at the company
FirstAidTraining Boolean A field that indicates whether an employee has completed a first aid training course or not

Example of the records of the tblEmployees table:
32
Table: tblHourLogs This table contains the information of the hours worked which is logged by the staff daily.

Field name Data type Description
LogID  AutoNumber A unique number assigned to an employee's daily working hours
EmployeeID Text (8)  A unique ID that identifies the employee to whom the hours logged belongs
LogDate  Date/Time  The date on which the hours were logged 
HoursWorked  Number The number of work hours logged for a specific employee for the day 

Example of the first eleven records of the tblHourLogs table:
33
NOTE:

  • Connection code has been provided.
  • The database is password-protected, therefore you will not be able to access the database directly.

The following one-to-many relationship with referential integrity exists between the two tables in the database:
34

Last modified on Thursday, 17 March 2022 07:22