After seeing your first program, a local tax business, Oiler Tax Pros, has hired you to expand upon your already existing code to calculate retroactive tax data for an individual over the past several years. They’ve organized the tax info for these years into an input file with a specific format to help make your job as a programmer easier.
Oiler Tax Pros input file starts with a year on one line. Then, tax bracket data will be listed in the format: tax bracket percentage, followed by whitespace, followed by the lower dollar limit for that bracket Once all tax brackets have been listed for a particular year, a line with -1 appears. Then the next year starts and the process repeats. After the last tax bracket in the last year, -1 will again appear. After that, -2 will appear to indicate the end of data to be read. Refer to tax_brackets.dat for an example (available on Blackboard). You should use this file to test your code.
To calculate taxes for a customer, there will be a second input file. This input file will have the customer’s name on the first line, followed by their social security number (SSN) on the second line. Then, a list of salaries will follow. Each salary listed will correspond to one year in tax_brackets.dat. In the example files, salary 40000 will correspond to year 2013, salary 38000 will correspond to the year 2012, and so on. Refer to customer_tax.dat for an example (available on Blackboard). You should use this file to test your code.
The goal of your program will be to create a receipt, similar to project 1, but for as many years as there are salaries listed in customer_tax.dat. All output should be written to a file called tax_receipt.txt. A possible strategy to get you started is as follows:
1) Read in the customer name and SSN from customer_tax.dat. Then read in the first salary. Print the name and SSN to the output file using the same style as the example below.
2) Read in the first year from tax_brackets.dat. Using two parallel arrays (initialize their sizes to 20 and call them taxBracketPct[] and taxBracketFloor[]), read in each tax bracket percentage and corresponding floor value from the file until -1 is read, storing them into the appropriate arrays. Make sure to keep a counter, numTaxBrackets, as you read in the data.
3) Calculate the tax owed for that year (use a for loop to loop over taxBracketPct[] and taxBracketFloor[] to calculate this).
4) Output the year, salary, and tax owed to the output file using the same style as the example below.
5) Repeat steps 2-4 until either there are no more salaries to be read from customer_tax.dat OR you reach the end of tax_brackets.dat. In the latter case, output a message at the very end of the output file stating that there were more salaries input than you have retroactive data for.
Three sample input customer files, along with a sample tax bracket file (from the IRS for years 2015 retroactively back through 2000) are provided on blackboard to test with.
For this assignment, you may assume that all SSNs are exactly 9 digits long and start with a non-zero. You must use manipulators to ensure that all percentages are written to one decimal place and that all monetary values are written to the nearest dollar (i.e. use fixed and set the precision as 0). Dots should also be filled between a label and its corresponding value (just like in assignment 1). Your output must still fit into a nicely formatted “box;” however, your box will be formatted similar to the next page. In the box, make sure that there are separating dashed lines (---) between each section of output and a line of asterisks (***) at the top and bottom of the output box (see below).
A sample input file might look like:
Jake Spettle
882244550
40000
38000
36000
33000
26000
The corresponding output file, then (assuming you use the tax_brackets.dat file that I provide you with), would look like: