20120129

Java Project #8 : Tax Program


/**
 * TaxProgram compute tax according to marital status and income.
 * 
 * @author (Andrew Samuels) 
 * @version (02-19-2010)
 */

//import scanner
import java.util.Scanner;

public class TaxProgram
{

    public static void main(String[] args)
    {
        //create variables
        int income;
        int taxAmount;
        String maritalStatus;
        
        //create scanner
        Scanner keyboard =  new Scanner(System.in);
        
        //capture income from user
        System.out.print("Please enter income: ");
        income = keyboard.nextInt();
        
        //capture marital status from user
        System.out.print("Please enter marital status (single, married): ");
        maritalStatus = keyboard.next();
        
        //determine tax amount from marital status and income
        if ((maritalStatus.equals("single") || maritalStatus.equals("Single")) && income < 30000)
        {
            taxAmount = income * 1/5;
            System.out.println("Tax amount is: " + taxAmount);
        }
        else if ((maritalStatus.equals("single") || maritalStatus.equals("Single")) && income > 30000)
        {
            taxAmount = income * 1/4;
            System.out.println("Tax amount is: " + taxAmount);
        }
        else if ((maritalStatus.equals("married") || maritalStatus.equals("Married")) && income < 50000)
        {
            taxAmount = income * 1/10;
            System.out.println("Tax amount is: " + taxAmount);
        }
        else if ((maritalStatus.equals("married") || maritalStatus.equals("Married")) && income > 50000)
        {
            taxAmount = income * 3/20;
            System.out.println("Tax amount is: " + taxAmount);
        }
    }
}