Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Adjusted Income The tax owed depends on the Adjusted Income, which in turn depends on the annual gross income and the number of exemptions. For

Adjusted Income

The tax owed depends on the Adjusted Income, which in turn depends on the annual gross income and the number of exemptions. For single taxpayers, the number of exemptions is one more than the number of dependents. For married taxpayers, the number of exemptions is two more than the number of dependents. For married taxpayers, the annual gross income is the sum of the incomes of both domestic partners, and for single payers the annual gross income is the income of the individual.

A certain amount of the annual gross income is exempt from taxes. The exempted amount is computed as follows: If the total number of exemptions is less than 5, then the exempted amount is computed by multiplying the number of exemptions by 5,000. Otherwise, the exempted amount is computed by multiplying the number of exemptions by 4,500.

The adjusted income is computed by subtracting the exempted amount from the annual gross income.

For example, consider a single taxpayer with an annual gross income of 60,000 having 3 dependents. The number of exemptions is 3 + 1 = 4. The exempted amount is 4 * 5,000 = 20,000. Thus, the adjusted income is 60,000 20,000 = 40,000.

Consider a couple with incomes of 35,000 and 30,000 with 4 dependents. The couples annual gross income is 35,000 + 30,000 = 65,000. The number of exemptions is 2 + 4 = 6. The exempted amount is 6 * 4,500 = 27,000. Thus, the adjusted income is 65,000 27,000 = 38,000.

Tax Rate

The tax rate is computed based on the tax bracket to which the adjusted income belongs. If the adjusted income is at most zero, the tax owed is zero. For single taxpayers, the tax table for adjusted income is as follows.

Tax Bracket Rate

Adjusted income <= 21,450 15%

Adjusted income > 21,450 but <= 51,900 28%

Adjusted income > 51,900 31%

For married taxpayers, the tax table for adjusted income is as follows.

Tax Bracket Rate

Adjusted income <= 35,800 15%

Adjusted income > 35,800 but <= 86,500 28%

Adjusted income > 86,500 31%

Consider a single taxpayer whose adjusted income is 60,000. The tax is calculated as follows: For the first 21,450 the rate is 15% which amounts to 21,450 * 0.15 = 3,217.50. For the amount between 21,450 and 51,900 the rate is 28% which amounts to (51,900 21,450) * 0.28 = 8,526. For the amount over 51,900 the rate is 31% which amounts to (60,000 51,900) * 0.31 = 2,511. Thus, the total tax is 3,217.50 + 8,526 + 2,511 = 14,254.50.

Consider a married couple whose adjusted income is 60,000. The tax rate is 15% for the first 35,800 which is 35,800 * 0.15 = 5,370. Since the adjusted income is less than 86,500, the tax rate for the remaining income is 28% which is (60,000 35,800) * 0.28 = 6,776. Thus, the total tax owed is 5,370 + 6,776 = 12,146.

Your Task

Your tax is to write a program named TaxReturn. The program should prompt the user to enter the filing status, the income of the individual, the income of the spouse (if appropriate), and the number of dependents. The filing status should be entered as either single or married in lower case. Note that if the filing status is single the program should not prompt the user to enter the spouses income. Based on the information entered the program should compute the total tax owed and print it out in a nice format.

Output Format

The program should output two lines of information. For example, for a single individual with annual gross income of 60,000 and 3 dependents, the output should be in the following format.

Filing Status Annual Gross Income Dependents Tax Owed

single 60,000 3 8,411.50

A few things to note about the second line. The values in the second row must be left justified and aligned appropriately with the headings on the first line. The decimal separator must be used when displaying numbers (e.g., 60,000) and tax owed (e.g., 8,411.50). When displaying floating point (real numbers), only two digits after the decimal point must be displayed. Read Section 2.3.2 (Pages 50 to 52) of the textbook for more information on how to format output.

Validating the Input

Your program must be robust to handle invalid input. If the user types in invalid input, then the program should quit by displaying an appropriate message. There are three scenarios where your program should check for invalid input.

(1) When prompted for filing status, the user enters neither single nor married.

(2) When prompted for number of dependents, the user types either a negative number or types in a non-integer value.

(3) When prompted for income, the user types either a negative number or a non-number.

For each case above, the program must display the message Invalid Input and quit. You can use the hasNext method available in Scanner to check if the input contains a number of the proper type.

For example, stdin.hasNextInt() peeks ahead at the input stream to check if the next item to be read is an integer. The method stdin.hasNextDouble() can be used to check if the next item to be read is of type double. Read Section 3.8 (Pages 116 to 118) of the textbook for more information on input validation.

Use of Constants

It is a good practice to use named constants to explain the meaning of literals used. Declare constants named RATE1, RATE2, and RATE3 for the three tax rates. This is done as follows:

final double RATE1 = 0.15;

final double RATE2 = 0.28;

final double RATE3 = 0.31;

Also define appropriate constants for single payer bracket levels (21,450 and 51,900) and married payer bracket levels (35,800 and 86,500).

Coding Conventions

You must follow good coding conventions. Variable names must be meaningful and start with lowercase letters. Your code must be properly indented (because you will have to use several nested if-else statements). Your code must have appropriate comments. Failure to follow good coding conventions will cause you to lose points even if your solution is correct.

Grading of Project 3

For this program you have do the following tasks in order:

START EARLY.

Develop as many test cases as possible with their expected output. Be exhaustive in developing test cases.

Draw a flowchart (or write pseudo code) describing your program logic.

Seek help on (2) and (3) from the TAs or instructor.

Only then should you start writing any code in Java.

Distribution of Points

Submit your work in items (2) and (3) above as Recitation 7 by 9:50 AM on Oct. 17. This will be graded as Recitation 7 and worth 20 points.

10 points: Use of meaningful variable names, constants, and generous use of comments in your program

50 points: For correctness and proper formatting of output etc., according to the specifications stated in this programming project.

Submission Instructions

Recitation 7: Submit the Test cases and Flowchart (or pseudo code) as a PDF or Word file by 9:50 AM on Wednesday, Oct. 17.

The program is due by midnight on Wednesday, Oct. 24.

Submit only the .java file via Canvas, if you have several .java files for this project, compress them before you submit. DO NOT submit the .class files or the whole project folder. Make sure that the name of .java file is TaxReturn (When you create a new class, you should type the class name as TaxReturn).

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

Students also viewed these Databases questions

Question

7-16 Compare Web 2.0 and Web 3.0.

Answered: 1 week ago