CSE114 Spring 2016 Lab Exercise 2 of Week 2 Compute Tax Chen-Wei Wang Problem Suppose an imaginary income tax scheme, where the calculation is based on: 1. filing status (single filing or married filing) 2. taxable income Once the above information is given by the user, the tax is calculated based on the following scheme: Tax Rate Single Filing Status Married Filing Status 10% $0 – $8,350 $0 – $16,700 15% $8,351 – $33,950 $16,701 – $67,900 25% $33,950+ $67,900+ That is, a tax payer’s income is split into up to three parts, depending on how high their income is. Once split, each part of the income is taxed with the corresponding rate. For a single filer, the cutoff points are $8,350 and $33,950. For a married filer, the cutoff points are $16,700 and $67,900. As an example, consider Jim who is a single filer and whose income is $186,476. Since his income is higher than the second cutoff point for a single filer (i.e., $33,950), his income will be split into 3 parts: – The first $8,350 is taxed with a rate of 10%. – The subsequent $(33,950 - 8,350) is taxed with a rate of 15%. – The final $(186,476 - 33,950) is taxed with a rate of 25%. Important Exercise Before You Proceed: Try the tax calculation for Jonathan, who is a married filer and who has a lower income $33,500. How would his income be split with this lower income? How would his income tax then be calculated? Your Task Your task is to write a Java program for the above tax calculation. Proceed as follows: 1. Create a Java class ComputeTax in Eclipse. Define your solution as the implementation body of the main method. 2. Prompt the user for their name, so that you can mention their name in later questions. 3. Ask the user to an integer value that indicates their filing status: 1 for Single Filing and 2 for Married Filing. If the entered status is neither 1 nor 2, then your program must terminate with a proper error message printed to the console. 4. Given that the entered filing status is valid, ask the user for the amount of their taxable income. 1 5. Split the income into parts, calculate the corresponding tax amounts, then sum them up. 6. Output to the console to inform the user about: – The total amount of tax they should pay; – Which scheme the calculation was based on (Single Filing or Married Filing); – Breakdowns of the tax amounts for each part of their income. Here are five expected runs of your program (notice that user input values are in bold faces): 1. Enter your name: Jim Jim, enter your filing status (1 - Single Filing; 2 - Married Filing): 0 Illegal status: 0 2. Enter your name: Jim Jim, enter your filing status (1 - Single Filing; 2 - Married Filing): 3 Illegal status: 3 3. Enter your name: Jim Jim, enter your filing status (1 - Single Filing; 2 - Married Filing): 1 Jim, enter your texable income: 186476 Jim, you should pay $42806.5 Calculation is based on the scheme of Single Filing: Part I: $835.0 Part II: $3840.0 Part III: $38131.5 4. Enter your name: Jim Jim, enter your filing status (1 - Single Filing; 2 - Married Filing): 2 Jim, enter your texable income: 186476 Jim, you should pay $38994.0 Calculation is based on the scheme of Married Filing: Part I: $1670.0 Part II: $7680.0 Part III: $29644.0 5. Enter your name: Jim Jim, enter your filing status (1 - Single Filing; 2 - Married Filing): 1 Jim, enter your texable income: 33500 Jim, you should pay $4607.5 Calculation is based on the scheme of Single Filing: Part I: $835.0 Part II: $3772.5 2