Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

You will find the prepared code fragments for the questions under the following subfolders:

Question 1 => Subfolder ExX1

Page 1 of 4 TPG201T – PAPER X


Question 1 [33]

Background

You are requested to create a C++ Builder application that will read phone call data from a file,
determine the duration of each call and calculate the total call duration for a selected provider.

Figure 1: Full running Application (Question 1)

The csv file MonthData.csv contains the following data as fields separated by “#” (hashes). The file can
be found under the subfolder “Data” on the level of your prepared source code.

An excerpt of the file follows:

Figure 2: First few "records" of the file "MonthData.csv"

Page 2 of 4 TPG201T – PAPER X


- The first field is the date of the call in the format DD/MM/YYYY
- The next two fields are the starting time of the call and the ending time of the call in the format
HH:MM:SS
- The next field is the 3-digit extension from which the call was made in the office (This text file
represent the records of a company and their internal telephone system and all the calls that
were made by the different employees from their respective office phones.)
- The next field indicates the number that was dialed and
- The last field the network that was accessed (provider)

The application you are about to develop makes use of standard components from the VCL. You will be
asked to complete four prepared events and one self-defined method. Tasks to be completed in short:
➢ Load file data into a list box
➢ Implement your own method to calculate phone-call duration
➢ Populate the duration column (merged into the existing list box contents – an inserted column!)
➢ List all unique appearing Service Providers
➢ Calculate the total call duration running through a selected Provider
Two methods called Heading1() and Heading2() are defined and provided to you. You may use them as
needed.

Question 1.1 (8)

1.1 Complete the code for the button [1. Load Billing Data] as part of the onClick-event provided.
Your code has to fulfill the minimum descriptions as follows:
• Instantiate a TStreamReader (VCL-) object and connect to the contents of the provided
data file: MonthData.csv into it. Note the position of the data file!
• While reading line by line from the file make sure to replace all “#” (hashes) with tabs.
• Add each line to the provided list box.
• Indicate the amount of all loaded records on label: lblCalls.

Question 1.2 (3)

1.2 Define a class wide method and name it: CallDuration(). This method accepts two parameters:
a.) The start time of a phone call as AnsiString and
b.) The end time of a phone call as AnsiString.

It returns the duration of the phone call in seconds. The data type to be returned is an integer. This
method will be used in the next events.

Question 1.3 (7)

1.3 Supply the code for the onClick-event of button [2. Calc Call Duration].

This event has to run through all lines of the list box (records) and calculate the duration for each
phone call. The duration has to be added as a fourth column to the list box. For calculation purposes
make use of the self-defined method in question 1.2.

Page 3 of 4 TPG201T – PAPER X


Disable button btnDuration. Take note of the new heading being used after adding the duration
column data. Also be sure to add the duration as fourth column – see arrow.

Figure 4: The duration for each phone call added as fourth column

Question 1.4 (5)

1.4 Code the onClick-event of button [3. List Providers].

The code has to populate the only provided radio group box with unique
appearing Service providers. See Figure 5 for an expected output.

An additional option is added in first position, which is called “ALL”.

Figure 5: All unique Service Providers listed with additional option “ALL”

Question 1.5 (10)

1.5 Code the onClick-event of the radio group box, which has the task to sum
up all single phone calls (in terms of duration) for the selected Service
Provider.

If the option “ALL” was selected the sum should include the talking time of
each and every phone call listed. For our sample the selection “ALL”
should deliver a total talking time of 12:55:49 (12 hours 55 minutes and 49
seconds).

The total duration output has to be formatted as indicated in Figure 6.

Figure 6: The total talking time (duration) of the service provider “Telkom”

Page 4 of 4 TPG201T – PAPER X

You might also like