Assignment title: C++
Question
CSC2402 Object-Oriented Programming
Q
Create a C++ application which will read a file of daily payments, calculate the total as well as the average
payment, display the results to the screen and write the results to a file. The input and output file names
should be provided as command line arguments.
task_3.cpp
The task_3.cpp file holds the main() function which is responsible for the following functionality:
Extracts the input file name and output file name from the command line arguments.
o If the number of command line arguments is not correct, throw an exception. The exception
class is Argc_error : public logic_error.
o The exception handler should display a prompt for the correct usage and exit. Please use
the same phrasing shown in the sample runs below.
Calls the appropriate openFile() function (see description below) to open the relevant files. If the file
name returned by openFile() is different from the one originally specified in the command line,
require the user to confirm to proceed with processing or to quit. Please use the prompts shown in
the sample runs provided below.
Reads the input file line by line, and extracts the relevant payment.
o Check if the extracted payments are valid. Throw an exception if the payment is not a
number – all characters are digits from 0‐9. The exception class for errors is Digit_error :
public logic_error.
o If the payment is not valid, the exception handler will skip the line, and display a message.
Please use the same error messages shown in the sample runs below.
o A sample input data file, data.txt, is shown below and provided in your A3 zip file. Each line
has the first 40 char for the name, then 10 char space for the payment, and the rest of the
line for comments.