Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a c++ program that can be used to calculate the federal tax obligation (amount of taxes owed) using the following information: For a single

Write a c++ program that can be used to calculate the federal tax obligation (amount of taxes owed) using the following information:

For a single person, the standard exemption is $2,500

For married people, the standard exemption is $5,500

Personal exemption is $650 per person

A person may put UP TO 4% of his/her gross (total income before taxes) in a pension plan. This can be 0, but not over 4%

Tax rates/amounts are:

15% - Taxable Income between $0 and $20,000

$2,000 plus 25% of taxable income OVER $20,000 Taxable Income between $20,001 and $50,000

$8,000 plus 35% of taxable income OVER $50,000

Calculate the taxable income as follows:

Subtract the sum of (1) the standard exemption, (2) the amount contributed to a pension fund, and (3) the personal exemption from the Gross income. For example, if a married couple has two (2) children, personal exemption is 4 x $650 = $2,600. If a single person has 1 child, personal exemption is 2 * $650 = $1,300.00.

Do NOT include the pension as an exemption (in the exemption total), include it as a deduction.

Tax obligation (taxes owed) will be calculated against the taxable income using the Tax Rates indicated above.

Request the name of the input file from the user. Do not hard-code the file name in the program.

Check the state of all file opens. If any file does not open properly, display an appropriate message and exit the program.

Read the file using a looping construct that checks for the end of file (not the number of rows in the data file).

Evaluate the marital status using a SWITCH statement.

Use the provided data file with the following information (taxCustomers.txt).

Each ROW of data contains:

Surname of family / single individual (last name only)

Marital status represented by a character (M, S)

Number of children under the age of 14 may be 0

Gross salary (before taxes)

Percentage of gross salary contributed to pension fund. This may be 0. This will be a percentage, not an amount, i.e., .04 will mean 4%.

For each row of input in the data file, output the following to the CONSOLE (screen) in a neat, readable format. Output each input line on one output line. Use manipulators to output values in readable columns. Use dollar signs before monetary values. All numerical values must have 2 decimal points. Use headings to indicate values displayed (you DO NOT need to use the following as headings, you may use your own):

Surname of the family (last name only)

Gross Income

Total exemption amount (does not include pension deduction)

Pension deduction amount in dollars (not the percentage)

Taxable Income

Tax obligation (taxes owed)

For each row of input in the data file, output the following to an OUTPUT FILE, name of your choice (in addition to the console) in a neat, readable format. Output each input line on one output line. Use manipulators to output values in readable columns. Use dollar signs before monetary values. All numerical values must have 2 decimal points. Use headings to indicate values displayed (you DO NOT need to use the following as headings; you may user your own).

You MAY hardcode the name of the output file, however, check the state of the open of the output file. If the open fails, output an appropriate message and exit the program:

Surname of the family (last name only)

Gross Income

Total exemption amount (does not include pension deduction)

Pension deduction amount in dollars (not the percentage)

Taxable Income

Tax obligation (taxes owed)

For 9 and 10, output must be in the following form, i.e., one heading for all lines for output:

Name Gross Income Total Exemptions Pension Deduction Taxable Income Tax Obligation

You MAY use abbreviations for headers to fit across the screen.

There will be ERRORS in the data file (see below for possible errors). If an error in the data is encountered, write the error and the line containing the error to a SECOND OUTPUT FILE, name of your choice (not the console). DO NOT PROCESS THE DATA; continue with the next input line. Only log the first error found in each line/row of data.

You MAY hardcode the name of the output error file, however, check the state of the open of the output file. If the open fails, output an appropriate message and exit the program:

Amount contributed to a pension fund MAY NOT be OVER .04. If the value in the input file is OVER .04, output the message Invalid Pension Percentage and the line of data containing the error on a separate line. No headings.

Marital Status must be S or M. If any other value, output the message Invalid Marital Status and the line of data containing the error on a separate line. No headings.

CLOSE ALL files before exiting the program.

input file

Krauss M 0 55000.00 .02 Tennant M 2 100000.00 .05 Grant S 0 142000.00 .04 Bing Q 1 55000.00 .03 Schuster S 2 175000.00 .0 Watt S 1 152000.00 .60 Smith M 1 70000.00 .03

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions