Calculate the total as well as the average payment

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

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.

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.

International Business Management l2 Consultation fee // error

Imperial Chemical 234 Pest control chemicals

National Home Appliances 34S6 Coffee machines // error

MicroHeart Software Consultancy 45678 Security audit

University of Silver Quartet 5678 Facility management

Telstar Satellite Communication 67O Connection fee // error

- 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.

Reference no: EM13739022

Questions Cloud

Writing a story on bible : I need help writing a story bible. Details in the descriptions. This is called a story bible. Minimum Word Count is 2000 words.
Advantages and disadvantages of incentive pay : List and explain the advantages and disadvantages of incentive pay, and describe how companies can overcome the disadvantages. (75 Words)
Discuss overchoice and assortment type : Rubbermaid's record of new product innovation is remarkable. With almost 5, 000 products, the firm continues to crank out a new one almost everyday - and with great success. It looks like traditional wisdom teaches us that a company may win market..
Write a one page single spaced regional overview paper : Write a one page single spaced regional overview paper.Writer Perspective: You are outsiders working closely with an established company
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
Explain the nature structure types of products : Specify the nature, structure, types of products or service of your chosen organization, and two (2) key factors in the organization's external environment that can affect its success. Provide explanation to support the rationale
Human resources in a global technological environment : Now let us take a look at what it takes to put it all together. How do you manage human resources in a global technological environment? How can an organization be strategic with their most important resource - their people? Explain your answer. Y..
How did the arrival of european explorers : How did the arrival of European explorers and Christian missionaries alter the course of history in East Asia? Did these Europeans cause positive or negative changes?
Why did the united states become involved in world war one : Why did the United States become involved in World War One? How did the Second World War impact the American home front?

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