INSTRUCTIONS AND INFORMATION
NOTE: Candidates must use the file DataENGNov2021.exe.
Do the following:
Once extracted, the following list of files will be available in the folder
DataENGNov2021:
Question 1:
Question1_P.dpr
Question1_P.dproj
Question1_P.res
Question1_U.dfm
Question1_U.pas
Question 2:
ConnectDB_U.pas
HikingDB - Copy.mdb
HikingDB.mdb
Question2_P.dpr
Question2_P.dproj
Question2_P.res
Question2_U.dfm
Question2_U.pas
Question 3:
HikingTrail_U.pas
Question3_P.dpr
Question3_P.dproj
Question3_P.res
Question3_U.dfm
Question3_U.pas
*.txt 9 files
*.jpg 9 files
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:
Example of the graphical user interface (GUI):
1.1 FormCreate event
Write code to change the format of the label lblQ1_1 as follows:
Example of output:
(4)
1.2Â Button [1.2 - Number of rolls]
Energy sweets recommended for hikers to have during each break while hiking are packaged in rolls of eight sweets per roll. Hikers normally eat four sweets during each break. Use the spnQ1_2 spin edit to select/enter the number of breaks a hiker plans on taking. The program must determine the number of sweet rolls that must be purchased for the hike.
Write code to do the following:
    Example of output for seven breaks:    Example of output for eight breaks:
(8)
1.3 Button [1.3 - Calculate volume]
The figure shown below was compiled using a combination of half a sphere and a tetrahedron (a solid shape with four flat sides that are triangles). The program must calculate and display the volume of the combined figure.
The following information is provided:
Use the information provided and write code to do the following:
Example of output:
(7)
1.4 Button [1.4 - Display pattern]
A pattern with a symbol selected from the cmbQ1_4 combo box must be displayed. The pattern is a square which consists of the same number of rows and columns. The number of rows and columns is obtained from the position of the symbol that has been selected from the combo box.
NOTE: The first item (@) in the combo box is situated in position one.
The first eight symbols in the combo box are shown below.
Write code to do the following:
Example of output if the first item (@) is selected in cmbQ1_4:
Example of output if the third item ($) is selected in cmbQ1_4:
(11)
1.5 Button [1.5 - Characters]
A string must be compiled by randomly generating upper-case letters of the alphabet until the same letter is generated consecutively.
Code has been provided to clear the rich edit and to initialise an output string.
Write code to do the following:
HINT: The ASCII values for the letters 'A' to 'Z' start at 65 for the letter 'A', 66 for the letter 'B', and so on up to the value of 90 for the letter 'Z'.
Example of output:
In the example above, the process was terminated because the letter 'U' was generated consecutively.
In the example above, the process was terminated because the letter 'C' was generated consecutively.
NOTE: The output your program generates may differ from the output examples, because the letters are randomly generated. The string that is generated can contain less or more characters than the strings supplied in the examples. (10)
TOTAL SECTION A: 40
SECTION B
QUESTION 2: SQL AND DATABASE PROGRAMMING
The database HikingDB contains information of members of different hiking clubs. The database contains two tables, namely tblClubs and tblMembers.
The data pages attached at the end of the question paper provide information on the design of the database and its contents.
Do the following:
NOTE:
 Variable |  Data type | Description |
 tblClubs |  TADOTable | Refers to the table tblClubs |
 tblMembers |  TADOTable | Refers to the table tblMembers |
2.1 Tab sheet [Question 2.1 - SQL]
Example of graphical user interface (GUI) for QUESTION 2.1:
NOTE: Code to execute the SQL statements and display the results of the queries is provided. The SQL statements assigned to the variables sSQL1, sSQL2, sSQL3, sSQL4 and sSQL5 are incomplete.
Use ONLY SQL code to complete the SQL statements for QUESTION 2.1.1 to QUESTION 2.1.5 that follow.
2.1.1 Button [2.1.1 - Clubs from Gauteng and SA affiliated]
Display the names and the towns of all clubs in Gauteng (GP) that are SA affiliated.
Example of output:
(3)
2.1.2 Button [2.1.2 - Birth year]
Display the name, surname and date of birth of all members who were born in 2002.
Example of output:
NOTE: The date format may differ from the example in the output. (3)
2.1.3 Button [2.1.3 - Display members]
Code has been provided to select a ClubName from the
cmbQ2_1_3 combo box.
Display the surname and name of members from the club selected in the combo box.
Example of output if Kamma Hiking is selected:
(4)
2.1.4 Button [2.1.4 - Average membership fee]
Display the province and the average membership fee per province where the average membership fee is more than R400.
The average membership fee per province must be a calculated field with the heading AvgFee and it must be displayed as currency.
Example of output:
(6)
2.1.5 Button [2.1.5 - Change member name]
Write code to change all member names spelled as 'Aiensley' to 'Ainsley'. (3)
2.2 Tab sheet [Question 2.2 - Delphi code]
Example of graphical user interface (GUI) for QUESTION 2.2:
NOTE:
2.2.1 Button [2.2.1 - Outstanding fees]
Write code to display the club name and annual membership fee as part of a heading and the surname, amount paid and outstanding fees for each club member in the redQ2_2_1 rich edit.
(12)
2.2.2 Button [2.2.2 - Update hikes completed]
Select a member from the tblMembers table in the dbgrid (dbgrdMany) who completed another hike.
Write code to increment the HikesCompleted field, by one for the member selected in the dbgrid. (4)
2.2.3 Button [2.2.3 - Add member]
Only the following clubs allow new member to join:
Mountain Free
Boks Hiking
Printfoot Hiking
The IDs and names of these clubs are listed in the rgpQ2_2_3 component in the following format: <ClubID>. <ClubName> with the caption 'Clubname'.
Code has been provided to assign the surname, name, date of birth and membership code of a new member to variables.
NOTE: To add a new member, the user must first select a club name from the rgpQ2_2_3 radio group.
Write code to do the following:
NOTE: You can add the member ONCE only. If you want to test your code by adding the member again, first restore the database to its original content before testing the code again. (5)
TOTAL SECTION B: 40
SECTION C
QUESTION 3: OBJECT-ORIENTATED PROGRAMMING
Do the following:
Example of graphical user interface (GUI):
NOTE: For this question, you are NOT allowed to include any additional attributes or user-defined methods unless explicitly stated in the question.
3.1 The incomplete object class (THikingTrail) provided contains code for the declaration of five attributes that describe a HikingTrail object.
The attributes for a HikingTrail object have been declared as follows:
Attribute  | Description |
 fTrailName |  The name of the hiking trail |
 fTerrainType |  The type of terrain, e.g. Rocky |
 fNumberOfDays |  The number of days it takes to complete the trail |
 fDistance |  The total distance of the hiking trail in kilometres |
 fCostPP |  The cost to book the hiking trail per person |
A constructor that assigns parameter values to the attributes has been provided.
Complete the code in the object class as described in QUESTION 3.1.1 to QUESTION 3.1.5 below.
3.1.1 Write an accessor method called getNumberOfDays for the fNumberOfDays attribute. (2)
3.1.2 Write a method calcDistPerDay to calculate and return the average number of kilometres that must be completed per day to complete the trail within the required number of days, rounded off to the nearest integer. (3)
3.1.3 Write a method called determineLevel to determine and return the difficulty level of the trail as a string. The difficulty level can be advanced, moderate or easy.
Write code to do the following:
3.1.4 Write a method called calcTotalCost to receive the number of hikers in a group as a parameter and return the total cost for the group, based on the fCostPP attribute value. (4)
3.1.5 Write a toString method to return all the attributes of the object in the following format:
<Name of hiking trail>: <Type of terrain>
<distance> km in <number of days> days
Cost per person: <Cost> formatted to currency
Example:
Amatola Hiking Trail: Rocky
100 km in 6 days
Cost per person: R1500.00Â (4)
3.2 An incomplete program has been supplied in the Question 3 folder. The program contains code for the object class to be accessible and declares an object variable called objHikingTrail.
Write code to perform the tasks described in QUESTION 3.2.1 to QUESTION 3.2.4.
3.2.1 Combo box - cmbQ3_2_1
Information on hiking trails are provided in different text files.
The name of the hiking trail, as provided in the combo box cmbQ3_2_1, is the same as the name of the text file. The extension of all text files is '.txt'.
Each text file contains four lines of information in the following format:
Type of terrain
Total distance in km
Total number of days
Cost of booking the trail for one person
For example, the content of the text file Amatola Hiking Trail is:
Rocky
100
6
1500
Code has been provided to extract the selected hiking trail from the combo box cmbQ3_2_1 and to display an image of the hiking trail in the image component.
Each time the name of the hiking trail is selected in the combo box, a new object must be instantiated.
Write code to do the following:
Example of output:
(8)
3.2.2 Button [3.2.2 - Display hiking trail details]
Write code to use the toString method to display the object's information in the redQ3_2_2 component.
Example of output if the Amatola Hiking Trail is selected:
(2)
3.2.3 Button [3.2.3 - Display cost]
Write code to do the following:
Example of output if the Amatola Hiking Trail is selected and the size of the group is 7:
(4)
3.2.4 Button [3.2.4 – Calculate distance per day]
Write code to use the object's methods and display the difficulty level and recommended distance per day in the following format for the selected hiking trail in the redQ3_2_4 rich edit:
You have to cover at least <distance per day> km per day to complete this <difficulty level> hiking trail in <number of days> days.
Example of output if the Amatola Hiking Trail is selected:
Example of output if the Rim of Africa hiking trail is selected:
(3)
TOTAL SECTION C: 40
SECTION D
QUESTION 4: PROBLEM-SOLVING PROGRAMMING
Hikers use a distance chart to plan their hiking trips. Checkpoints refer to rest areas or overnight locations on a hiking trail. A distance chart consists of the distances between different checkpoints on a hiking trail.
Do the following:
Example of the graphical user interface (GUI):
The following have been provided in the program:
4.1 Button [4.1 - Display distance chart]
Write code to display the names of the checkpoints from the array, arrNames, and the contents of the two dimensional array, arrDistances, in neat columns in the rich edit redQ4 provided.
NOTE: The intersection between two of the same checkpoints has a value of 0.
Example of output:
NOTE: Tabs and blank lines in the example output are included for readability and are NOT required as part of the output of the program.
(5)
4.2 Button [4.2 - Validation]
Some of the values in the distance chart in the array arrDistances were rounded down to an integer value. These inaccurate integer values need to be replaced by the more accurate decimal value in the corresponding row and column.
Write code to do the following:
For example:
The value at arrDistance[1,3] must be the same as the value at arrDistance[3,1], the value at arrDistance[4,2] must be the same as the value at arrDistance[2,4] and so on.
Example of output:
Example of the updated two-dimensional array:
(8)
4.3Â Button [4.3 - Route planner]
Hikers can select one of different routes listed in the cmbRoutes combo box to do a hiking trail.
The hiker must select a possible route in the combo box.
If the hiker selects the route '4,3,1,2,5', it means that the hiking trail starts at the Beacon checkpoint. The route then continues towards the Cintsa, Morgan and Haga Haga checkpoints with Gonubie being the last checkpoint.
An itinerary needs to be compiled and displayed for the route selected.
Write code to do the following:
Example of output if the selected route is 4,3,1,2,5:
Example of output if the selected route is 2,4,3,5,1:
TOTAL SECTION D:Â 30
GRAND TOTAL:Â 150
INFORMATION TECHNOLOGY P1 (2)
DATABASE INFORMATION QUESTION 2:
The design of the database tables is as follows:
Table: tblClubs
The table contains the information of hiking clubs in different provinces.
Field name | Data type | Description |
ClubID (PK) | Number | A unique number assigned to the club |
ClubName | Text (20) | The name of the hiking club |
ClubTown | Text (25) | The town where the club is situated |
Province | Text (20) | The province where the club is situated |
SA_Affiliated | Boolean | Boolean field indicating whether the hiking club is affiliated with the SA hiking club or not |
MemFee | Currency | Annual membership fee |
Example of the first ten records in the tblClubs table:
Table: tblMembers
This table contains the information of members in different hiking clubs.
Field name | Data type | Description |
MemberCode (PK) | Text (7) | A unique code assigned to each member |
MemberSurname | Text (20) | The surname of the member |
MemberName | Text (20) | The name of the member |
BirthDate | Date/Time | The birthday of the member |
HikesCompleted | Number | The total number of hikes completed by the member |
AmountPaid | Currency | The amount paid by the member towards the membership fee |
ClubID (FK) | Number | A number that connects the member to the club where the member is registered |
Example of the first ten records in the tblMembers table:
NOTE: Connection code has been provided.
The following one-to-many relationship with referential integrity exists between the two tables in the database: