// Arup Guha
// 7/9/03
// This program asks the user for their annual income and calculates the
// user's tax. Although this program does not use actual tax brackets, it
// simulates the basic idea of how taxes are done in brackets.

import java.util.*;

public class Tax {

	// Levels for each tax bracket.
    final public static int p15_bracket = 5000;
    final public static int p20_bracket = 15000;
    final public static int p28_bracket = 35000;
    final public static int p30_bracket = 50000;
    final public static int p33_bracket = 80000;
	
	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		System.out.println("What is your annual income?");
		int salary = stdin.nextInt();

		double tax_amt = 0;
		double taxable_sal = salary - p15_bracket;

		// Taxing 15% bracket.
		if (taxable_sal > 0) {

			// Highest bracket for the user.
			if (taxable_sal < p20_bracket - p15_bracket) {
				tax_amt = tax_amt + 0.15*taxable_sal;
				taxable_sal = 0;
			}

			// Not the highest bracket for the user.
			else {
				tax_amt = tax_amt + 0.15*(p20_bracket-p15_bracket);
				taxable_sal = taxable_sal - (p20_bracket-p15_bracket);
			}
		}

		// Taxing 20% bracket.
		if (taxable_sal > 0) {

			// Highest bracket for the user.
			if (taxable_sal < p28_bracket - p20_bracket) {
				tax_amt = tax_amt + 0.20*taxable_sal;
				taxable_sal = 0;
			}

			// Not the highest bracket for the user.
			else {
				tax_amt = tax_amt + 0.20*(p28_bracket-p20_bracket);
				taxable_sal = taxable_sal - (p28_bracket-p20_bracket);
			}
		}

		// Taxing 28% bracket.
		if (taxable_sal > 0) {

			// Highest bracket for the user.
			if (taxable_sal < p30_bracket - p28_bracket) {
				tax_amt = tax_amt + 0.28*taxable_sal;
				taxable_sal = 0;
			}

			// Not the highest bracket for the user.
			else {
				tax_amt = tax_amt + 0.28*(p30_bracket-p28_bracket);
				taxable_sal = taxable_sal - (p30_bracket-p28_bracket);
			}
		}

		// Taxing the 30% bracket.
		if (taxable_sal > 0) {

			// Highest bracket for the user.
			if (taxable_sal < p33_bracket - p30_bracket) {
				tax_amt = tax_amt + 0.30*taxable_sal;
				taxable_sal = 0;
			}
  
			// Not the highest bracket for the user.
			else {
				tax_amt = tax_amt + 0.30*(p33_bracket-p30_bracket);
				taxable_sal = taxable_sal - (p33_bracket-p30_bracket);
			}
		}

		// Tax all remaining income at 33% if necessary.
		if (taxable_sal > p33_bracket)
			tax_amt = tax_amt + 0.33*taxable_sal;

		// Output tax.
		System.out.println("For your salary $"+salary+" your tax is $"+tax_amt);
	}
}
