INSTRUCTIONS AND INFORMATION
Once extracted, the following list of files will be available in the folder
DataSept2021:
Question 1:
Question 2:
Question 3:
Question 4:
QUESTION 1: GENERAL PROGRAMMING SKILLS
Do the following:
Your school has created a club to provide information and conduct research on water supply and rainfall issues. Complete the program for the club by using the instructions below.
1.1 Button [1.1 Display]
Write code to do the following:
Load the image named rain.jpg into the image component named imgRain.
Enable the panel named pnlBath.
Change the background colour of the panel, named pnlRain, to aqua. (3)
1.2 Button [1.2 Process]
Rainfall calculator.
How many 150 litre baths can be filled after rainfall has occurred over a certain area in your garden or on your roof?
Write code to do the following:
The user will enter the height and width in the spinedits named sedWidth and sedHeight and choose the number of millimetres from the combobox named cmbRain.
The number of 150 litre baths will be equal to the number of square meters multiplied by the amount of water in millimetres and divided by 150. Round the answer to 1 decimal place.
Example: An area of 20 m by 35 m receives 1/2 millimetre (0.5 mm) of rain.
20 x 35 x 0.5 /150 = 2.3 baths (150 litres each)
Use the following data to test your solution:
Rainfall in mm | Height in Metres | Width in Metres | Number of 150 litre baths |
15 | 9 | 10 | 9 |
1/10 | 20 | 20 | 0.3 |
1/2 | 20 | 35 | 2.3 |
30 | 9 | 12 | 22 |
Example of output:
(11)
1.3 Button [1.3 Find rainfall type]
We wish to find out what type of rainfall occurred in our area.
The following descriptions apply for different amounts of rain that falls in 1 hour.
No rain: Less than 1 mm per hour
Moderate rain: Greater than or equal to 1 mm per hour, but less than 4 mm per hour.
Heavy rain: Greater than or equal to 4 mm per hour, but less than 8 mm per hour.
Very heavy rain: Greater than or equal to 8 mm per hour but less than 10 mm per hour.
Heavy shower: Greater than or equal to 10 mm per hour, but less than or equal to 50 mm per hour.
Flood: Greater than 50 mm per hour.
Write code in this button onclick event to determine the type of rainfall that occurred. The user will enter the amount of rain in millimetres per hour in the edit box named edtRain and then the program must calculate and display, in the label named lblRainfallType, the description of the type of rainfall as described above.
You must also write code to test if an integer has been entered into the edit box named edtRain. If the input is not an integer an error message must be displayed, and the procedure must exit.
Examples of output:
(13)
1.4 Button [1.4 Display Rainfall]
You are required to calculate and display how many times either 5 mm or 10 mm of rainfall was recorded in 8 different areas.
Write code to repeat the following instructions 8 times:
Example of output after 1 execution of the button onclick event showing that 1 area experienced 5 mm of rainfall and 2 areas experienced 10 mm of rainfall:
Example of output after more than one execution of the button onclick event:
(13)
[40]
QUESTION 2: DATABASE PROGRAMMING
The database Birds.mdb contains the details of birds and the status of birds in South Africa. The database contains two tables, namely Bird and Status.
Table: Status
This table contains the descriptions of the possible status of a bird.
Field name | Data type | Description |
StatusID | Number | A unique number assigned to each status |
StatusName | Text (50) | The description of the Status of a bird |
Example of data in the Status table:
Table: Bird
This table contains information of birds and their sightings in South Africa.
Field name | Data type | Description |
BirdID | Number | A unique number assigned to a bird |
Birdname | Text (50) | The common name of a bird |
Vagrant | Yes/No | Bird wanders beyond the limits of their natural range — can turn up almost anywhere |
Sightings | Number | Total number of sightings of a bird |
Lastsighted | Date (short date) | Date that the bird was last seen |
StatusID | Number | Foreign key to connect to the Bird table |
Example of data of the first fourteen records of the Bird table:
The relationship between the two tables is shown below:
Do the following:
The user interface is displayed below:
NOTE:
Variable | Data type | Description |
tblStatus | TADOTable | Refers to the table named Status |
tblBird | TADOTable | Refers to the table named Bird |
2.1 In this section you may ONLY use 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.
Do the following to complete the incomplete SQL statements assigned to the variables sSQL1, sSQL2, sSQL3, sSQL4 and sSQL5 per question respectively.
2.1.1 Button [2.1.1]
Write SQL code to display all Status details sorted in reverse alphabetical order of StatusName.
Example of output:
(3)
2.1.2 Button [2.1.2]
Write SQL code to display the BirdName of all birds that have had less than 200 Sightings.
Example of output:
(3)
2.1.3 Button [2.1.3]
The user must enter the name of a bird. Code has been provided for the bird name “vulture” to be entered in an input box and saved in a variable named sline.
Write SQL code to display the BirdName and LastSighted date of all birds that contain the word stored in the variable, sline.
Example of output:
(4)
2.1.4 Button [2.1.4]
Write an SQL code to delete all birds that have not been assessed and where the status is listed as ‘Least concern’. The StatusID for ‘Not Assessed’ is the number 6 and the StatusID for ‘Least Concern’ is the number 5.
(Code has been written to display the successfully updated table after deleting.)
Example of output of the first 9 records:
(4)
2.1.5 Button [2.1.5]
Write SQL code to display the StatusName and BirdName of all birds.
Example of output of the first 8 records:
(3)
2.1.6 Button [2.1.6]
Write SQL code to display the average quantity for each StatusI birds that were LastSighted in the year 2007 using the descr ‘AverageSightings’. The average must be rounded to 2 decimal p D of all iption laces.
Example of output:
(8)
2.2 In this section, only Delphi programming code may be used to answer QUESTION 2.2.1 and QUESTION 2.2.2.
Use the global variables, tblStatus and tblBird, provided.
NO marks will be awarded for SQL statements in QUESTION 2.2.
2.2.1 Button [2.2.1]
Write code to display all Birdnames which contain the word ‘EAGLE’ in the richedit named redDisplay.
Example of output:
(6)
2.2.2 Button [2.2.2]
All birds that are categorised as vulnerable must be changed to the status of endangered.
Write code to change the StatusID to 2 of all birds that have a StatusID of 3.
Count how many changes have been made and display the result in the richedit named redDisplay.
Example of output:
(9)
[40]
QUESTION 3: OBJECT-ORIENTED PROGRAMMING
Birding is defined as a recreational activity by people called birders to identify and observe wild birds in their natural habitat. There are many wild birds that can be sighted by birders in various biological communities in the Eastern Cape. |
Do the following:
The following user interface is displayed:
Complete the code for this program, as specified in QUESTION 3.1 and QUESTION 3.2.
3.1 The incomplete class (Tsighting) contains the declaration of five attributes that describe the objBirder object.
NAMES OF ATTRIBUTES | DESCRIPTION |
fName | The name of the person who is a birder |
fArea | The name of the area where the bird was first sighted |
fBird | The name of the bird that was sighted |
fDate | The date that the first sighting of the bird occurred |
fQuantity | The total number of sightings so far |
Complete the code in the object class, as described in QUESTION 3.1.1 to QUESTION 3.1.5 below.
3.1.1 Write code for a constructor method named Create that will receive the name of a birder (person doing the bird watching), area, bird and date of sighting as parameters.
Assign these parameter values to the correct attributes and initialise the attributes for the quantity of birds sighted to ONE. (4)
3.1.2 Write code for a method named getSightings which returns the quantity of bird sightings. (2)
3.1.3 Write code for a method named IncreaseQuantity that will receive one integer parameter to set the quantity of sightings by adding the parameter to the attribute named fQuantity. (4)
3.1.4 Write code for a method name SightingGap which must calculate the number of years that have transpired after the first sighting of a bird took place. Use the current date and the attribute named fDate to return the number of years as a string with the words ‘years since first sighting’ joined to the end of the string.
Example of output: ‘23 years since first sighting.’ (7)
3.1.5 Write code for a method named toString which must return a string.
The string must contain the attributes of the class joined together in the following format:
Example of output:
3.2 An incomplete unit Question3_u.pas has been provided.
It contains code for the object class to be accessible and has a global objec variable, objBirder, already declared.
Do NOT delete or change any provided code. t
Follow the instructions below to code the solution:
3.2.1 Button Q3.2.1
The user will enter a birder’s name, choose a sighting area and bird name and enter the date that the bird was first sighted using the provided input components named edtBirderName, cmbArea, rgpBirds, sedDay, sedMonth and sedYear.
Write code to do the following:
Use a method of the class to display the birder’s name, the bir name, the number of years that have passed since first sighting, t area of the sighting and the date of the first sighting.
Example of output:
(11)
3.2.2 Button Q3.2.2
Write code to receive the input from the spinedit named sedSighting.
Use the methods of the class to do the following:
Example of output if 3 more sightings was added to the quantity:
(5)
[38]
QUESTION 4: PROBLEM-SOLVING PROGRAMMING
Technically, there is no beginning point of the water cycle, but when asked ‘Where does the water cycle start?’, people have different answers. A survey was conducted with many people who answered this question. You will use the data from this survey to perform calculations and display the answers.
Do the following:
Example of the text file named water.txt:
Complete the code for each question, QUESTION 4.1 and QUESTION 4.2.
NOTE:
Given:
A global array named arrTypes has been declared.
A global array named arrQty has been declared.
A global array counter name iCount has been declared.
A global totalling variable name iSum has been declared.
4.1 Button Q4.1
Write code to do the following:
Example of output:
(19)
4.2 Button Q4.2
Write code to calculate the percentage of each quantity in arrQty using the global variable iSum. Round the answer to no decimal places.
Example: percentage = quantity for a type chosen / sum of all choices x 100 Display the percentages as a symbol for each of four categories.
The FOUR categories consist of the following:
Display a symbol (x) in a neat grid to display the range of percentages for each type from arrTypes.
Example of output:
(13)
[32]
TOTAL: 150