Uploaded by lilithamhlantla26

12 IT P1 WCape Eng Jun 2023

advertisement
<SCHOOL BADGE>
<SCHOOL NAME>
INFORMATION TECHNOLOGY P1
JUNE 2023
MARKS: 150
TIME: 3 hours
This question paper consists of 20 pages, 2 data pages and 2 pages for planning.
Information Technology
Practical paper - Paper 1
INSTRUCTIONS AND INFORMATION
1.
This paper is divided into FOUR sections. Candidates must answer ALL the
questions from 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 the Delphi programming
language 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 name and surname 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. Your name and surname must appear on all the printouts. 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.
Copyright reserved
2
Information Technology
13.
Practical paper - Paper 1
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 DATA_P1Jun2023.exe.
Do the following:
•
•
•
Double click on the password-protected executable file.
Click on the 'Extract' button.
Enter the following password: 123News&
Once extracted, the following list of files will be available in the folder:
DATA_P1Jun2023:
Question1:
Question1_P.dpr
Question1_P.dproj
Question1_P.res
Question1_U.dfm
Question1_U.pas
Question2:
BackupDB.mdb
DataModule_u.dfm
DataModule_u.pas
Question2_P.dfm
Question2_P.dpr
Question2_P.dproj
Question2_P.res
Question2_U.dfm
Question2_U.pas
ShoppingDB.mdb
TDBConnection_U.pas
Question3:
clsArtwork.pas
Question3_p.dpr
Question3_p.dproj
Question3_p.res
Question3_u.dfm
Question3_u.pas
Question4
Butterfly200m.txt
Question4_p.dpr
Question4_p.dproj
Question4_p.res
Question4_u.dfm
Question4_u.pas
Copyright reserved
3
Information Technology
Practical paper - Paper 1
SECTION A
QUESTION 1: GENERAL PROGRAMMING SKILLS
Do the following:
•
•
•
Open the incomplete program in the Question 1 folder.
Enter your name and surname 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 graphical user interface (GUI):
Follow the instructions below to complete the code for EACH section of
QUESTION 1, as described in QUESTION 1.1 to QUESTION 1.4.
Copyright reserved
4
Information Technology
1.1
Practical paper - Paper 1
Button [1.1 - Register]
A new student needs to be registered and a new email for the student will be
generated.
Enter values for the surname in the edtSurname edit box and a cell number in
the edtCellNumber edit box.
Write code to:
 Test if data was entered for the surname and the cell number.
 If no surname or no cell number was entered:
o Change the font colour of the label lblMessage to red and set the
label lblMessage to visible.
 If the edit fields contain information:
o Extract the surname from edtSurname and the cell number from
edtCellNumber.
o Set the label lblMessage to be not visible.
o Generate an email address for the student according to the
following instructions:
 Add the surname and the last 3 digits of the cell number to
make up the username part of the email address.
 Add “@fakedomain.com” to the back to complete the email
address for example: Smith543@fakedomain.com.
 Display the email in the edtEMail edit box
Example of output if the surname and/or email address were not entered:
Example of Input and output:
(10)
Copyright reserved
5
Information Technology
1.2
Practical paper - Paper 1
Button [1.2 - Calculate]
Interest rates are based on the academic performance of the students. The
two categories that determine the students interest rates are Merit and
Standard.
A Merit students’ interest rate is 0.01%.
A Standard students’ interest rate is 0.0125%.
The following formula can be used to calculate the monthly payment:




M is the monthly payment
P is the loan amount
J is the monthly interest rate
N the total number of payments
Write code to do the following:
 Determine the interest rate (J) based on the category selected in the radio
group rgpCategory.
 Extract the period of the loan (N) from cmbPeriod and convert the years to
months.
 Extract the loan amount (P) from the edit edtLoan.
 Use the formula provided to calculate the monthly payments (M).
 Display the monthly payments (M) as currency on the label lblBursary.
Examples of input and output:
(14)
1.3
Button [1.3 - Bursary]
A student can apply for a bursary. The bursary amount is determined based
on the student’s mark.
The table below is used to determine bursary amount.
Average
95% – 100%
80% – 94%
63% – 79%
< 62%
Copyright reserved
Bursary amount
R10 000
R8 000
R1 000
No bursary
6
Information Technology
Practical paper - Paper 1
Write code to do the following:
 Input the students mark from the spin edit spnAverage.
 Determine the bursary amount that a student qualifies for using the table
provided.
 Display the bursary amount on the label lblBursary.
Example of possible input and output:
(7)
1.4
Button [1.4 – Generate and display]
Use a conditional (While or repeat) loop to determine and display random odd
numbers in the range 15 to 25 (both included). As soon as the sum of these
numbers are larger than 180 the loop must stop.
Display the odd numbers in the first line of the memOutput component.
Display the sum of the numbers in the second line of the memOutput.
Example of output:
(9)
●
●
●
Enter your name and surname as a comment in the first line of the program file.
Save your program.
Print the code if required.
TOTAL SECTION A:
Copyright reserved
7
40
Information Technology
Practical paper - Paper 1
SECTION B
QUESTION 2: SQL AND DATABASE
Scenario
A company is launching a new loyalty program called "ShopMore" that rewards
customers every time they make a purchase at one of the stores in the different areas
in Cape Town. Customers can earn points when they make a purchase with their loyalty
card.
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 name and surname 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.
Example of graphical user interface (GUI):
● 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.
Copyright reserved
8
Information Technology
Practical paper - Paper 1
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
tblCustomers
Data type
TADOTable
tblPurchases
TADOTable
2.1
Description
Refers to the table
tblCustomers
Refers to the table
tblPurchases
Tab sheet [Question 2.1 - SQL]
Example of the graphical user interface (GUI) for QUESTION 2.1:
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.
2.1
Complete the SQL statements to perform the tasks described in QUESTION
2.1.1 to QUESTION 2.1.5 that follow.
Copyright reserved
9
Information Technology
Copyright reserved
Practical paper - Paper 1
10
Information Technology
2.1.1
Practical paper - Paper 1
Button [2.1.1 - Customers]
Display the first name, last name and date of birth of all women in the
tblCustomers table. Sort the data, on the date of birth field, for the
youngest lady to be at the top of the list.
Example output of the first few records on the next page:
(4)
2.1.2
Button [2.1.2 - GMail]
Display the first name, last name and email address of all customers
who have a Gmail email address (i.e., the email address ends with
"@gmail.com").
Example output of the first few records:
(3)
2.1.3
Button [2.1.3 – May transactions]
Display the purchase date, store and amount spend from the
tblPurchases table of all transactions from the 1st to the 24th of May
2023 of the Brackenfell and Durbanville stores.
Example output of the first few records:
NOTE: The date format of your output might differ from the screenshot
above.
Copyright reserved
11
(6)
Information Technology
2.1.4
Practical paper - Paper 1
Button [2.1.4 – Number of purchases]
Display the store and the number of purchases made at each store in the
tblPurchases table. Only include stores where the total number of
purchases is greater than or equal to 40.
Example of output:
(5)
2.1.5
Button [2.1.5 - Customers]
Read a store name from the combo box cmbStore and then display the
First_Name, Last_Name and Amount of all clients that purchase from
the selected shop.
Example output of the first few records if Blouberg was selected:
(5)
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:
Copyright reserved
12
Information Technology
2.2.1
Practical paper - Paper 1
Button [2.2.1 – Purchase item]
Olivia Jones purchased some items to the value of R 525.75 from the
Parow store on 20 May 2023. This transaction was never captured on
the system.
Write code to add this record to the database.
See example output below:
(7)
2.2.2
Button [2.2.2 – Customer points]
This loyalty program reward customers at the end of the year. A person
receives 1 point for every R10 they spend. They want to know what the
current number of points for each customer are.
Write code to calculate and display the customer’s name, surname and
points in the redOutput component.
Example output below:
(10)
●
●
●
Enter your examination number as a comment in the first line of the program file.
Save your program.
Print the code if required.
TOTAL SECTION B:
Copyright reserved
13
40
Information Technology
Practical paper - Paper 1
SECTION C
QUESTION 3: OBJECT-ORIENTATED PROGRAMMING
Scenario
A small art gallery exhibits and sells artworks of a number of local artists. The artists range
from being newly discovered, to emerging artists that are beginning to build a reputation,
as well as well-known, established artists. The artworks range from drawings and
paintings to sculptures and ceramic work.
The gallery would like to be able to list the details of each artwork and also to be able to
determine the potential commission that the gallery could earn if they sold all the works
of a particular artist.
Do the following:
●
●
●
Open the incomplete program in the Question3 folder.
Open the incomplete object class clsArtwork.pas.
Compile and execute the program.
The following user interface is displayed with limited functionality:
Complete the code as specified in QUESTION 3.1 and QUESTION 3.2 that follow.
NOTE:
You are NOT allowed to add any additional attributes or user-defined methods, unless
explicitly stated in the question.
Copyright reserved
14
Information Technology
3.1
Practical paper - Paper 1
The provided incomplete object class (TArtwork) contains the declaration of five
attributes which describe an artwork object.
The attributes for an artwork object have been declared as follows:
Attribute
Description
fArtist
fTitle
fCategory
fValue
fStatus
The name of the artist
The title of the artwork
The type of artwork: drawing, painting, sculpture, ceramic
The price of the artwork in Rand
The status of the artist such as discovered, emerging, wellknown
You have been provided with the skeleton of a toString method.
Complete the code in the object class as described in QUESTION 3.1.1 to
QUESTION 3.1.6 below.
3.1.1
3.1.2
3.1.3
Write code for a constructor method that will receive the artist’s name, the title of
the artwork, the category into which the artwork falls and the value of the artwork
as parameters.
 Assign the parameter values to the respective attributes.
 Assign the default value 'Unknown' to the status attribute.
(4)
Write the code for a mutator method called setStatus that receives a value for the
artist’s status as parameter.
(3)
Write the code for a method called calculateCommission that will return the
commission that the gallery will earn on the sale of an artwork.
Commission is earned as the following percentages on the different types of
artworks:
 Ceramic: 10%
 Drawing: 12%
 Painting: 18%
 Sculpture: 20%
3.1.4
3.1.5
Write code for a method called changeValue that will receive the discount
percentage (integer) as a parameter.
 The discount amount must be calculated as a percentage of the original
value of the artwork.
 The value of the artwork must then be updated by subtracting the
discount offered.
Write code for an accessor method called getValue that will return the value of
the artwork.
Copyright reserved
15
(6)
(3)
(2)
Information Technology
3.1.6
Practical paper - Paper 1
Write code to complete the toString method that has been provided to return a
string with all the attributes of the object in the following format:
Artist:
<Artist>
Artwork name:
<Title>
Category:
<Category>
Value:
<Value> (formatted to Currency)
Status:
<Status>
Example output when the program is complete:
(2)
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 objArtwork.
Write code to perform the tasks described in
QUESTION 3.2.6 below.
3.2.1
QUESTION 3.2.1 to
Button [3.2.1 - Instantiate object]
Write code to do the following:
 Extract the artist’s name from the edtArtist edit box, the title of the artwork
from the edtTitle edit box, the category of the artwork from the
rgpCategory radio group, and the value of the artwork from the edtValue
edit box.
 Use the information to instantiate a new Artwork object.
 Display a message on a message box to show that the details have been
registered as shown below.
(5)
3.2.2
Button [3.2.2 – Set status]
Write code to do the following:
 Extract the artist’s status from the cmbStatus combo box.
 Call the object’s setStatus method to update the status of the artist.
3.2.3
(2)
Button [3.2.3 – Artist details]
Write code to do the following:
 Call the object’s toString method to display the details of the artwork and
artist on the redDisplay rich edit as shown in the example below.
Copyright reserved
16
(1)
Information Technology
3.2.4
Practical paper - Paper 1
Button [3.2.4 – Commission]
Write code to do the following:
 Call the object’s calculateCommission method to determine the
commission that the gallery would earn when the current artwork is sold.
 Display the commission below the artwork details on the redDisplay rich
edit in Rand as shown in the example below.
(2)
3.2.5
Button [3.2.5 – ON SALE!]
Write code to do the following:
 Generate a random discount percentage in the range 5% to 15% (including
these values).
 Call the object’s changeValue method passing the discount amount
generated above as its parameter to update the value of the artwork.
 Call the object’s toString method to display the artwork’s updated details.
 Display the discount given below the artwork details on redDisplay as
shown in the example below.
(3)
3.2.6
Button [3.2.6 – Commission per Artist]
You have been provided with four parallel arrays containing the details of 15
artworks currently in the gallery. They contain the artist name, the title of the
artwork, the category of the artwork, and the value of the artwork respectively.
arrArtists: array[1..15] of String = ('Mannie Douglas', 'Irene Ngoma',
'Olive Green', 'Olive Green', 'Irene Ngoma', 'Salma Naidoo', 'Mannie
Douglas', 'Irene Ngoma', 'Olive Green', 'Ellis MacMillan', 'Olive
Green', 'Ellis MacMillan', 'Salma Naidoo', 'Mannie Douglas', 'Salma
Naidoo');
arrTitle: array[1..15] of String = ('Moonscape I', 'Africa II', 'Study
in green', 'Portrait of Ella', 'Ceres sunset', 'Ocean waves', 'Abstract
VII', 'Leaves - a vision', 'The homestead', 'Suzie', 'The runners',
'Vase III', 'The mist', 'VASE IX', 'Platter II');
Copyright reserved
17
Information Technology
Practical paper - Paper 1
arrCategory: array[1..15] of String = ('Painting', 'Painting',
'Painting', 'Drawing', 'Painting', 'Ceramic', 'Sculpture', 'Drawing',
'Painting', 'Drawing', 'Sculpture', 'Ceramic', 'Painting', 'Ceramic',
'Ceramic');
arrValue: array[1..15] of Real = (8350.00, 15625.95,
3750.00, 9800.25, 7580.00, 11899.99, 9500.50, 8205.10,
8900.25, 6420.45, 15500.00, 10200.95, 7450.00);
10250.25,
10250.25,
The gallery owners would like to know how much commission they stand to earn
from the sale of the artworks they have in the gallery for a particular artist.
Write code to do the following:
 Extract the selected artist’s name from the lstArtist list box.
 Loop through the array of artists (arrArtists) and find all the matches to
the selected artist.
 Each time a match is found, instantiate an objArtist object using the
corresponding values from the four arrays.
 Use the object’s calculateCommission method to add the commission
that stands to be earned from each of the selected artist’s works arrays to
a running total that will determine the total possible commission earnings
from that artist.
 Keep track of how many artworks there are in total for the selected artist.
 Display the number of artworks held by the gallery for the specific artist on
the lblNumWorks label as shown in the example below.
 Display the total amount of commission that the gallery stands to earn from
the sale of the artist’s work in Rand on the lblCommission label as shown
in the example below.
(7)
●
●
●
Enter your name and surname as a comment in the first line of the object class and
the form class.
Save your program.
Print the code in the object class and the form class if required.
TOTAL SECTION C:
Copyright reserved
18
40
Information Technology
Practical paper - Paper 1
SECTION D
QUESTION 4: PROBLEM-SOLVING PROGRAMMING
The 2022 Commonwealth Games was an international multi-sport event for members of the
Commonwealth of Nations that took place in Birmingham, England between 28 July and 8
August 2022. One of South Africa’s athletes, Chad le Clos, won a silver medal in the men’s
200m butterfly men event.
Looking forward to the Olympic Games 2024, we would like to look closer at the men’s 200m
butterfly event result of the Commonwealth Games 2022 to access some of the main
contenders for this event at next year’s Summer Olympic Games.




Compile and execute the incomplete program in the Question4 folder.
The program has no functionality currently.
Code has been provided to handle the required button activation and deactivation.
The following user interface is displayed:
NOTE: Question 4 consist of 4 sub questions, QUESTION 4.1 to QUESTION 4.4.
The program contains the code shown below for the declaration and default
population of three global parallel arrays.

The 3 parallel arrays (arrNames, arrCountries and arrResults) are declared
globally with a maximum size of 8 elements as follows:
arrNames: array [1 .. 8] of string = ('Surname Name1', 'Surname
Name2', 'Surname Name3', 'Surname Name4', 'Surname Name5',
'Surname Name6', 'Surname Name7', 'Surname Name8');
Copyright reserved
19
Information Technology
Practical paper - Paper 1
arrCountries: array [1 .. 8] of string = ('Country1', 'Country2',
'Country3', 'Country4', 'Country5', 'Country6', 'Country7',
'Country8');
arrResults: array [1 .. 8] of real =
(1.11, 2.22, 3.33, 4.44, 5.55, 6.66, 7.77, 8.88);
A text file called Butterfly200m.txt is provided and contains 8 lines of data. The
data in the text file is stored in the following format:
<Surname and name>#<Country>#<Result in seconds>
Example of the first 3 lines of data in the text file:
Clareburt Lewis#New Zealand#116.76
Gough Bowen#Australia#117.53
Guy James#England#118.30
Explanation of the first three lines of data in the Butterfly200m.txt text file:



Lewis Clareburt from New Zealand completed the 200m butterfly in 116.76 seconds
Bowen Gough from Australia completed the 200m butterfly in 117.53 seconds
James Guy from England completed the 200m butterfly in 118.30 seconds
Complete the code for QUESTION 4.1 – Question 4.4.
4.1
Button [4.1 – Display]
Write code to do the following:
 Display the content of the three arrays arrNames, arrCountries and arrResults
in neat columns as shown below in redQ4.
Example output:
(4)
4.2
Button [4.2 – Read]
Write code to the following:
 Test if the text file Butterfly200m.txt can be accessed.
o If the file is not accessible, display an appropriate message to indicate that
the file cannot be accessed and leave the procedure.
o If the text file can be accessed, use the text file Butterfly200m.txt to populate
the arrays arrNames, arrCountries and arrResults with the data from the
text file.
 Display a suitable message that the arrays have been successfully
populated.
Copyright reserved
20
Information Technology
Practical paper - Paper 1
Example output:
(12)
NOTE: Code is provided to call the button btnQ4_1 to display the arrays.
4.3
Button [4.3 – Sort]
Write code to sort the three parallel arrays according to the results (from shortest
time to the longest time).
Example output:
(8)
NOTE: Code is provided to call the button btnQ4_1 to display the arrays.
4.4
Button [4.4 – Final result]


Write code to calculate the average result by making use of the global variable
rAverage that has been provided.
The average must be displayed in redQ4 in minutes and seconds as shown
below.
Example output:
(6)
●
●
●
Enter your name and surname as a comment in the first line of the program file.
Save your program.
Make a printout of the code if required.
TOTAL SECTION D:
GRAND TOTAL:
Copyright reserved
21
30
150
Information Technology
Practical paper - Paper 1
INFORMATION TECHNOLOGY P1
DATABASE INFORMATION QUESTION 2:
The design of the database tables is as follows:
Table: tblCustomers
The table contains the information of tour guides employed by the agency.
Field name
Cust_ID
First_Name
Last_Name
Email
Gender
DOB
Data type
AutoNumber
Short Text
Short Text
Short Text
Short Text
Date/Time
Description
Unique ID for the customer
Name of the customer
Surname of the customer
Email address of customer
Gender of customer
Date of birth of customer
Example of the records in the tblCustomers table:
tblCustomers
Cust_ID First_Name Last_Name
1 Lungelo
Nkosi
2 Mpho
Makwela
3 Thabo
Modise
4 Nomvula
Zulu
5 Musa
Mthembu
6 Lindiwe
Khumalo
7 Nkosi
Nkosi
8 Ayanda
Nkosi
9 Mpho
Molefe
10 Thabo
Mahlangu
Email
lungelo.nkosi@example.com
mpho.makwela@example.com
thabo.modise@example.com
nomvula.zulu@example.com
musa.mthembu@example.com
lindiwe.khumalo@example.com
nkosi.nkosi@example.com
ayanda.nkosi@example.com
mpho.molefe@example.com
thabo.mahlangu@example.com
Gender
Male
Female
Male
Female
Male
Female
Male
Female
Male
Male
DOB
1995/05/12
1982/11/22
1998/08/08
1976/02/19
1990/07/27
1987/04/03
2001/01/01
1994/09/18
1996/06/07
1988/03/25
Table: tblPurchases
The table contains the information on the different transactions when customers purchase
goods at the listed stores.
Field name
Trans_ID
Cust_ID
Store
Amount
Purch_Date
Copyright reserved
Data type
AutoNumber
Number
Short Text
Short Text
Date/Time
Description
Unique number for each transaction
The ID of the customer who made the purchase
The store name
The amount spend when purchasing
Date of purchase
1
Information Technology
Practical paper - Paper 1
Example of the first ten records in the tblPurchases table:
tblPurchases
Trans_ID
Cust_ID
Store
41
27 Blouberg
172
22 Durbanville
129
23 Durbanville
138
25 Brackenfell
93
9 Century City
170
20 Brackenfell
105
24 Century City
3
5 Century City
66
17 Blouberg
167
20 Brackenfell
Amount
310.63
26.09
153.17
78.01
288.58
266.52
80.03
319.34
168.71
104.98
Purch_Date
2023/01/01
2023/01/01
2023/01/01
2023/01/03
2023/01/03
2023/01/03
2023/01/04
2023/01/05
2023/01/05
2023/01/07
NOTE: Connection code has been provided.
The following one-to-many relationship with referential integrity exists between the two tables
in the database.
Copyright reserved
2
Information Technology
Practical paper - Paper 1
INFORMATION TECHNOLOGY P1 – PLANNING PAGE 1
Copyright reserved
1
Information Technology
Practical paper - Paper 1
INFORMATION TECHNOLOGY P1 – PLANNING PAGE 2
Copyright reserved
2
Download