TaxCalculator.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program calculates a simple tax return.
  5  */
  6  public class TaxCalculator
  7  {  
  8     public static void main(String[] args)
  9     {  
 10        Scanner in = new Scanner(System.in);
 11  
 12        System.out.print("Please enter your income: ");
 13        double income = in.nextDouble();
 14  
 15        System.out.print("Are you married? (Y/N) ");
 16        String input = in.next();
 17        int status;
 18        if (input.equals("Y")) 
 19        {
 20           status = TaxReturn.MARRIED;
 21        }
 22        else  
 23        {
 24           status = TaxReturn.SINGLE;
 25        }
 26  
 27        TaxReturn aTaxReturn = new TaxReturn(income, status);
 28  
 29        System.out.println("Tax: "
 30              + aTaxReturn.getTax());
 31     }
 32  }