Calculate the total as well as the average payment

Assignment Help C/C++ Programming
Reference no: EM13750287

Task

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.

-  Line 1 has an error as "l2"has an alphabetic ‘l';
- Line 3 has an error as "34s6" has an alphabetic ‘s';
- Line 6 has an error as ‘67o" has an alphabetic ‘o';
- 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.
- See the sample runs below for the expected results for the data.txt file provided.
- Calculates the total as well as the average payment. Writes the results to the output file and displays it to the screen.
o See the sample runs below for the expected output for the data.txt file provided.

The task_3.cpp file also contains two openFile() functions, one each to open the input and output files. Each openFile() function should provide the following functionality:

- Attempts to open the passed in file name.

- If there is an error when opening the provided file name the function should throw an exception, passing whatever information is required to the exception handler. Please use the error messages shown in the sample runs below.

- The exception handler should display an appropriate error message and prompt the user to provide a new file name, again please use the prompts shown in the sample runs below. The exception handler should then recursively call openFile() passing the new file name. The openFile() function will continue to be recursively called until a file is successfully opened. In practice you would put a limit on the number of potential calls, in order to avoid infinite recursion. For this assignment please disregard this problem.

- The relevant exception class for the two openFile() functions are shown below.

o string openFile(ifstream& in, string str): Input file exception class is Readfile_error : public logic_error.

o string openFile(ofstream& out, string str): Output file Exception class is Writefile_error : public logic_error.

- Return the name of the opened file.

You may also find it convenient to include separate functions to perform required conversions from string to integer and dates to strings.


Attachment:- Code.zip

Reference no: EM13750287

Questions Cloud

Particular analytical measures : The particular analytical measures chosen to analyze a company may be influenced by all of the following except:
Dmv case study : Using the DMV Case Study and the Stakeholder Analysis Exercise spreadsheet provided, you will complete the three columns of the spreadsheet for each of the ten stakeholder groups listed on the spreadsheet
Change model assignment : Imagine that you are an executive for XYZ, Inc., a high-end retail chain that sells luxury watches, jewelry, and hand bags. You've just been put in charge of the company's first international expansion
Companys ratio of liabilities to stockholders equity : The following information was taken from Slater Company's balance sheet: Determine the company's ratio of fixed assets to long-term liabilities. Determine the company's ratio of liabilities to stockholders' equity.
Calculate the total as well as the average payment : 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.
Consolidated statement of retained earnings : On January 2, Year 1, Pool Co. acquired 75% of Kale Co.'s outstanding common stock. The balance sheet data at December 31, 20x1, show retained earnings of $200,000 per company. During 20x1, Pool and Kale paid cash dividends of $25,000 and $5,000, res..
Common measure of liquidity : A common measure of liquidity is
What is the amount of cash received : Buehler Company on June 15 sells merchandise on account to Chaz Co. for $1,000, terms 2/10, n/30. On June 20, Chaz Co. returns merchandise worth $300 to Buehler Company. On June 24, payment is received from Chaz Co. for the balance due. What is t..
Conduct a swot analysis of tesla motors : Conduct a SWOT analysis of Tesla Motors with specific discussion about what you think are the main strengths, weaknesses, opportunities, and threats facing Tesla

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd