CSU Banner

CS 163/164, Fall 2017

Programming Assignment - P4

Tax Computation

Due Monday, Feb. 12th at 6:00 pm

Late Tuesday, Feb. 13th at 8:00 am


Objectives of this Assignment

  1. To teach you to read input from the keyboard,
  2. to see if you can figure out an algorithm,
  3. to learn how to use conditionals (if/else if/else) statements,
  4. to print formatted output, and
  5. to understand how progressive taxation works!

Description

The program allows the user to input some of the information that normally appears on a tax form, then it calculates a tax bill according to the formulas described below. WARNING: Be aware that the tax computation shown here is greatly simplified and should not be used for calculation of your real taxes!

Instructions

For this assignment, you must follow directions exactly. Create a P4 project in Eclipse then write a class P4 with a main method, and put all of the following code into the main method:
  1. Instantiate a single Scanner object to read console input.
  2. Declare doubles for the gross salary, interest income, and capital gains.
  3. Declare an integer for the number of exemptions.
  4. Declare doubles for the total income, adjusted income, federal tax, and state tax.
  5. Print the prompt shown below and ask the user for their gross salary.
  6. The gross salary represents dollars, which can be entered with or without decimal points.
  7. Print the prompt shown below and ask the user for the number of exemptions.
  8. The number of exemptions is an integer.
  9. Print the prompt shown below and ask the user for their interest income.
  10. The interest income represents dollars, which can be entered with or without decimal points.
  11. Print the prompt shown below and ask the user for their capital gains income.
  12. The capital gains represents dollars, which can be entered with or without decimal points.
  13. Perform the calculation of federal total income, as shown in the Formula section.
  14. Perform the calculation of the federal adjusted income, as shown in the Formula section.
  15. Perform the calculation of the federal total tax, as shown in the Formula section.
  16. Perform the calculation of the state income tax, as shown in the Formula section.
  17. Print out the total income, adjusted income, total tax, and state tax.
  18. You may use integer or floating point for the computations.
  19. The output should always report exactly 2 digits after the decimal, so use System.out.printf.
  20. Your program should be accurate to within $0.01.
  21. Use variables to store everything, don't try to do all the calculation in a print statement!
  22. Do not hard code values, we will test your program with different values.
  23. You do not need to handle a negative adjusted income.
  24. The example below shows four lines of user input (in blue font), with prompts, followed by four lines of program output (in black font).
Salary: 92768.54
Exemptions: 8
Interest: 1234.50
Gains: 4400.99
Total Income: $93404.03
Adjusted Income: $84404.03
Total Tax: $15033.13
State Tax: $5486.26

Formulas

HINT: A helpful visual aid for the math portion is here. Total Tax computation: For the example above, we compute the Total Tax in the example above as follows:

13% * (35,000.00-20,000.00) = 1,950.00
23% * (50,000.00-35,000.00) = 3,450.00
28% * (84,404.03-50,000.00) = 9,633.13

Adding up the above we get a Total Tax of $15,033.13. That's a chunk of change! You can see the results of our other computations in output shown above.

State Tax = Adjusted Income * 6.5%

Specifications

Grading Criteria


Submit P4.java to the Checkin tab.


CS Banner
CS Building