Question: The file names must be as specified in the assignment and there must not be any unspecified prompts, or pauses or dummy reads at the

The file names must be as specified in the assignment and there must not be any unspecified prompts, or pauses or dummy reads at the end.

When you make your solution(s) and projects, be careful to make Console projects and to check the Empty project check box.

Your program will read a line-oriented data file, process the contents of the file, and produce formatted output on the console.

Lab 11 Hints:

The last field must be converted to a double.

You only need the last line highlighted in yellow.

Printing the last column as a double value rather than as a string makes it much easier to format the output.

The following statements illustrate how to configure cout to print U.S. currency; the program only needs to do these two operations once (i.e., they do not need to be inside of any loop).

cout.setf(ios::fixed); // fixed point output, no scientific notation cout.precision(2); // two places after the .

Program Requirements

Write a (non-object-oriented) C++ program (in a single file) that reads a data file that implements an old fashioned "checkbook register," prints a formatted table of checks and deposits (in file order), and calculates the balance by adding all of the deposits and subtracting all of the check amounts from a running total. The specific program requirements are as follows:

Name the program file check.cpp

Prompt the user for and read the name of the checkbook data file (some operating systems permit file names to contain spaces, so you program must accept file names with spaces). In the past a C-string would be required because the constructors and the open member functions of the stream objects didn't accept instances of the string class.

Read and parse each line of input. The input file format is as follows:

deposit:July 7:-:300 416:July 8:Albertsons:15.85 417:7/9:Checker Auto:19.95 418:7/10:Super Target:47.50 419:Dec 5:Home Depot:47.89 deposit:Dec 10:-:100 420:Dec 12:Lowes:200 

Your program must remove the colons from the input lines separating each line into four separate pieces of data

Lines that begin with "deposit" represent deposits: the second field is the deposit date; the third field is just a dash; the fourth field represents the deposit amount, which is added to the balance.

Lines that begin with a number represent checks; the second field is the date that the check was written; the third field is the recipient of the check; the fourth field represents the check amount, which is subtracted form the balance.

Your program must print and format the information contained in each line and print the final balance as shown below, all to the console:

----------------------------------------------------------------------- deposit July 7 - $ 300.00 416 July 8 Albertsons $ 15.85 417 7/9 Checker Auto $ 19.95 418 7/10 Super Target $ 47.50 419 Dec 5 Home Depot $ 47.89 deposit Dec 10 - $ 100.00 420 Dec 12 Lowes $ 200.00 ----------------------------------------------------------------------- Balance: $ 68.81 

You may NOT use any stdio functions (e.g., you may not use printf or scanf)

The first three fields are left justified; the fourth (money) field is right justifiedand aligned on the decimal point.

Align the decimal point in the balance with the decimal point of the numbers at the right in the table.

The exact field (i.e., column) width is left to your discretion, but, to allow the output to fit withing the console window, the the total line length may not exceed 79 characters

You may use loops to draw the lines or you may hard code them (there is also a clever way to do them)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!