// Arup Guha
// 7/13/04
// Solution to 2004 BHCSI Taxes program.

import java.io.*;
import java.text.DecimalFormat;

public class Taxes {

  public static void main(String[] args) throws IOException {

    BufferedReader stdin = new BufferedReader
				(new InputStreamReader(System.in));

    // Get income, marital status and student status.
    System.out.println("What is your yearly income?");
    double income = Integer.parseInt(stdin.readLine());
    System.out.println("Are you single(S) or married(M)?");
    char marital = stdin.readLine().charAt(0);
    System.out.println("Are you a student?(y/n)");
    char student = stdin.readLine().charAt(0);

    // Get homeowner information.
    System.out.println("Do you own your home?(y/n)");
    char homeowner = stdin.readLine().charAt(0);
    
    // Obtain interest paid for homeowners
    double interest = 0;
    if (homeowner == 'y' || homeowner == 'Y') {
      System.out.println("How much interest did you pay on your mortgage?");
      interest = Double.parseDouble(stdin.readLine());
    }

    // Marital status deduction.
    if (marital == 'M' || marital == 'm')
      income = income - 9000;

    // Single deduction.
    else
      income = income - 5000;

    // Student deduction.
    if (student == 'Y' || student == 'y')
      income = income - 6000;

    // Homeowner deductions.
    if (homeowner == 'Y' || homeowner == 'y') {
      income = income*.925;
      income = income - interest;
    }

    double tax=0.0;

    // Tax upper bracket of money.
    if (income > 30000)
      tax = tax + .3*(income-30000);

    // Tax income in middle bracket. The minimum is taken so that users
    // with incomes of less than 30000 have their tax calculated 
    // accurately.
    if (income > 10000)
      tax = tax + .2*(Math.min(income,30000)-10000);

    // Tax the first 10000 dollars of taxable income.
    if (income > 0)
      tax = tax + .1*Math.min(income,10000);


    // Use this to format output values to two decimal places.
    DecimalFormat money = new DecimalFormat("0.00");;
    
    // Print out the tax.
    System.out.println("Your tax for the year is $"+money.format(tax));

  }
}
