Вы находитесь на странице: 1из 2

Income Tax

/*
* Main.java
*
* Created on October 27, 2008, 9:05 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package incometax;
import java.text.*;

/**
*
* @author david johnson
*/
public class Main {

/** Creates a new instance of Main */


public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Please enter your income: ");
double income = MyInput.readDouble();
double incomeTax = calculateIncomeTax(income);
NumberFormat currency = NumberFormat.getCurrencyInstance();
System.out.println("The income tax is: " + currency.format(incomeTax));

public static double calculateIncomeTax(double income)


{
double tax = 0;
if (income <= 750)
{
tax = income * .01;
}
else if(income <= 2250)
{
tax = 7.5 + (income - 750) * 0.02;
}
else if(income <= 3750)
{
tax = 37.50 + (income - 2250)* .03;
}
else if(income <= 5250)
{
tax = 82.50 + (income - 3750)* .04;

}
else if(income <= 7000)
{
tax = 142.50 + (income - 5250)* .05;

}
else
{
tax = 230.0 + (income - 7000)*.06;
}

return tax;
}

Вам также может понравиться