1  import java.util.Scanner;
  2  
  3  /**
  4     This program computes income taxes, using a simplified tax schedule.
  5  */
  6  public class TaxCalculator
  7  {
  8     public static void main(String[] args)
  9     {  
 10        final double RATE1 = 0.10;
 11        final double RATE2 = 0.25;
 12        final double RATE1_SINGLE_LIMIT = 32000;
 13        final double RATE1_MARRIED_LIMIT = 64000;
 14        
 15        double tax1 = 0;
 16        double tax2 = 0;
 17  
 18        // Read income and marital status
 19        
 20        Scanner in = new Scanner(System.in);
 21        System.out.print("Please enter your income: ");
 22        double income = in.nextDouble();
 23  
 24        System.out.print("Please enter s for single, m for married: ");
 25        String maritalStatus = in.next();
 26  
 27        // Compute taxes due
 28  
 29        if (maritalStatus.equals("s"))
 30        {
 31           if (income <= RATE1_SINGLE_LIMIT)
 32           {
 33              tax1 = RATE1 * income;
 34           }
 35           else
 36           {
 37              tax1 = RATE1 * RATE1_SINGLE_LIMIT;
 38              tax2 = RATE2 * (income - RATE1_SINGLE_LIMIT);
 39           }
 40        }
 41        else
 42        {  
 43           if (income <= RATE1_MARRIED_LIMIT)
 44           {
 45              tax1 = RATE1 * income;
 46           }
 47           else 
 48           {
 49              tax1 = RATE1 * RATE1_MARRIED_LIMIT;
 50              tax2 = RATE2 * (income - RATE1_MARRIED_LIMIT);
 51           }
 52        }
 53        
 54        double totalTax = tax1 + tax2;
 55     
 56        System.out.println("The tax is $" + totalTax);
 57     }
 58  }