CS 157 Spring 2001

Assignment 4 – If statements (plus Calculations and I/O)

100 points

 

Assigned: 02/07/2002

Due: 02/14/2002 at the start of class

 

Pre-Lab (Do Before Lab):  Bring a new disk. Plan out sequence of statements needed for program. This is definitely a step up in complexity from what we’ve done before. Plan ahead!!

 

Main Assignment:

It’s tax time! Write a program that calculates the amount of tax that a taxpayer should have paid. Ask the user for their net income (this is income after all deductions and exemptions etc – we’ll save that stuff for a more advanced program). Then according to the simplified (for your benefit) tax schedule shown below, calculate the amount of tax and display the income and tax (as shown in the sample).

 

Tax Schedule (We are only handling Single taxpayers)

               Income                                                              Tax Rate

               First $25,000 in net income                 15%

               Next $35,000 in net income                 27%

               Remaining Income                                30%

 

Sample Questions to be asked of the user:

 

What is your net income (after deductions)?

 

 

Sample Results to be Displayed:

 

Tax Results:

      Income:           40000.0   

Tax Due:           7800.0  

 

Hand in:

 

Miscellaneous:

·        Define named constants. If the tax brackets were to change, we’d like to be able to just change a few numbers at the top of the program..

·        Please try to make the output of your program like mine, to aid my grading. (but note that we haven’t done anything yet with specifying how many decimal places to display)

·        You will need the SavitchIn.java file (still obtainable from my WWW page  - or from previous weeks).

·        You can use dialog boxes if you prefer, but make sure it doesn’t get in your way.

·        MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your program on the above example, but make sure you test it on other data as well - I will! Your program needs to be able to handle any valid inputs. Hint – what will cause the program to act differently?

·        If you have any questions about the tax scheme, please ask!!! Your calculations need to meet the requirements of the task.

·        Put YOUR NAME, and e-mail address in comments at the beginning of the program.

·        Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit.