You are to develop a budgeting report for a local company using a C++ program. There are two input files. The first input file lists the individual areas a budget has been defined for. Two of these are the two checking accounts where the budget is the amount of money in the accounts. The 'ledger.dat' file contains the list of budget areas.
A second file contains the list of invoices and written checks against a given budget.
You are to read in the second file 'journal.dat' and update the value in each of the budgeted areas.
Print out a report showing the budgets and their current values. Some will be under and other will be over budget.
Use an array of structures to hold the data. Use pointers to move through the array (no subscripts syntax). Read in the 'ledger.dat' and initialize the array of structs. Read in the 'journal.dat' and update the values in the array of structs.
Format of 'ledger.dat' file.
budget# budget name initialValue
Format of 'journal.dat' (More data on a line of input than you need.)
Budget# Number? date ExpenseAreaText ExpenseValue
ExpenseValue is a positive for cost and negative for deduction
Print out a nice table (using pointers) of the budget areas and the resulting balance.
Please find attached an implementation "503784.cpp" and corrected "journal.dat" file.
Please note that there are two issues with your "journal.dat" file.
1. The entry "565 1287 04/20/98 Electric^I^I 145.63" has two tab characters, as indicated by '^I' here. Rest of the entries in journal.dat and ledger.dat do not have tab characters at all.
The response works with the assumption that only space would be used in the ledger and journal entries.
2. Your "journal.dat" specifies negative expense values like "- 78.70", "- 500.00", ... . Since ExpenseValue is a single column, how can you have the negative sign separated from the values, sometimes by single space, sometimes by two spaces? It should be uniform representation of values in this column, like "-78.70", "-500.00", ... with no space character coming between the sign and the value. Presence of space there means we should have two columns there - one for sign and one for absolute value, however we have just single column for ExpenseValue.
This response ...
Attached program code has been tested compiling warning and error free, and working, using GNU C++ compiler "g++" version 4.3.4 . Please study this response thoroughly and formulate your own response in your style of writing code and comments, removing extra things that you do not need there - like this response prints the formatted ledger data as read from "ledger.dat" file as a cross-checking measure, and there are couple of error checks that you might not need.