INFORMATION TECHNOLOGY PAPER 1
GRADE 12
NOVEMBER 2020
NATIONAL SENIOR CERTIFICATE
INSTRUCTIONS AND INFORMATION
NOTE: Candidates must use the file DataENGJun2020.exe.
Do the following:
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:
Example of the graphical user interface (GUI):
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:
Example of the appearance of the combo box when the btnQ1_1 button is clicked: (4)
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
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:
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)
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:
Example of output if an integer value of 19 was entered:
Example of output if an integer value of 45 was entered: (11)
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:
Example of output if the word Win was entered:
Example of output if the word non-subscriber was entered:
Example of output if the words Team one were entered:
(17)
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:
NOTE:
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:
NOTE:
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)
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)
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)
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)
2.2 Tab sheet [Question 2.2 - Delphi code]
NOTE:
Example of the graphical user interface (GUI) for QUESTION 2.2:
2.2.1 Button [2.2.1 - Employees with first aid]
Write code to do the following:
NOTE: Code to display the column headings has been provided.
Example of output: (7)
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)
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:
Example of the content of the record if LogID 774 was selected and the value of 8 was entered for HoursWorked: (5)
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:
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:
|
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:
Example 1:
Container size: | M |
Storage period (months): | 3 |
Discount (%): | 0% |
Cost: | R5250.00 |
Example 2:
Container size: | S |
Storage period (months): | 6 |
Discount (%): | 10% |
Cost: | R5400.00 |
Example 3:
Container size: | L |
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:
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
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:
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)
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:
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:
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.
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:
Example of possible output:
Output for a different set of data generated: (18)
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:
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:
NOTE:
The following one-to-many relationship with referential integrity exists between the two tables in the database: