Text Fi es
Mock Test
Grade 11
Information Techno ogy
Download the data files at
[Link]
Question 1
Open the Project1 file from the Q1 sub-folder.
Each client has their own text file, which contains all the payments that they have made at the
beauty salon for each appointment. Each client’s text file has the following format:
Client<client number>.txt
For example: client 561’s data is stored in a text file called [Link].
Example of client 561’s text file:
Each text file contains multiple lines
where EACH LINE is the total paid for
that appointment.
For example, consider the text file,
[Link], shown on the left:
• The first line lists an appointment
that cost R350.
• The second line is an
appointment that cost R625.
1.1 Complete the code for the btnQ11 button that that prompts the user for a new appointment
payment (done for you and stored in the sPayment string variable) and takes as input a
client number via the spnClient spin edit control.
The code must then ADD the payment value as a new line to the client’s text file based on
the client number from the spnClient spin edit control (Determine the file name of the text
file based on the value given from the spnClient spin edit control).
No error checking to see if the text file exists is required and you can assume that the
client’s text file was already created beforehand so you only need to add to the current
existing text file.
The prices for different services that the Beauty Salon provides are stored in the [Link]
text file. Each line in the text file is in the following format:
Service’s name <open bracket>Category<close bracket><star character>Price
For example if a line from the text file reads:
Haircut(Hair)*300 then the Haircut service, which
falls in the Hair category, is priced at R300.
Example of the text file:
2
1.2 Complete the code for the btnQ12 button that takes as input the category from the
cmbxCategory combo box component (which can be a value of either ‘ ‘Hair’, ‘Nails’, ‘Wax’
or ‘ALL’) which has been done for you. The code then displays the service name, the
category and the price of all the services that match the category given as input, based on
the values from the PriceList text file. These details must be display in the redData rich
edit control as shown in the diagram below. Ignore the ALL option for now.
A message must be displayed if there is an error when reading from the text file.
Example of output if the user selects Nails from the cmbxCategory combo box:
1.3 Modify the code for the btnQ12 button so that if the user selects the value ‘ALL’ as input,
then all the services in the text file must be displayed.
Example of output if the user selects ALL from the cmbxCategory combo box:
3
Question 2
Open the Project1 file from the Q2 sub-folder.
The details about electrical items being used during the day are stored in the [Link] text
file. Each line in the text file is in the following format:
Item’s name <comma>Minutes item was used
For example if a line from the text file reads: TV,90 then the TV was used for 90 minutes. It is
possible that electrical items are used multiple times during the day, therefore having multiple
lines in the text file.
Example of the text file:
2.1 Complete the code for the btnQ21 button that takes as input the value from the cmbxItem
combo box component (done for you) and then calculates how many times and for how
many total minutes that selected item was used in the day, based on the values from the
DailyUsage text file.
The number of times the item was used and the total number of minutes the item was used
must be display. Display the details of the item in the redDisplay rich edit control as shown
in the diagram.
Example of output if the user selects TV from the cmbxItem combo box:
NOTE: Suitable error checking to see if the text file exists MUST also be done.
4
Your household electricity data for the month of March are stored in the [Link] text file. The
text file has only three lines. An example of the three lines with their description is given below:
Example of text file data Description of each line in text file
Units available and kWh used Text heading
175 Value representing your units available
63 Value representing the kWh used
2.2 Complete the code for the btnQ22 button that takes as input the number of units used (via
the sedUnits spin edit control) and number of new kWh added (via the sedKilowatts spin
edit control) in a week for the month of March and RECREATE the March text file with the
updated values:
• The inputted units value must be subtracted from the current value in the text file.
• The inputted kWh value must be added to the current value in the text file.
The text file must remain in the same format with the correct heading. You can assume that
the text file does exist.
For example: If the user gives 78 as the number of units used and 29 as the number of new
kWh added then resulting text file should look like this:
END OF MOCK TEST
Video answers to the above questions can be found on our channel at
For more IT & CAT related material find Mr Long IT and CAT on:
[Link]/@MrLongITandCAT
@mrlongeducation [Link]/MrLongEducation
[Link]/MLEWhatsAppChannel
Question 1: [Link]
Question 2: [Link]