Professional Documents
Culture Documents
Paper X
Paper X
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.
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.
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.
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.
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.
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.
Figure 4: The duration for each phone call added as fourth column
The code has to populate the only provided radio group box with unique
appearing Service providers. See Figure 5 for an expected output.
Figure 5: All unique Service Providers listed with additional option “ALL”
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).
Figure 6: The total talking time (duration) of the service provider “Telkom”