// Arup Guha
// 4/5/07
// Class for Spring 2007 COP 3330 Assignment #5
// This class manages the basic functionality for SalariedEmployees

import java.text.DecimalFormat;

public class SalariedEmployee extends Employee {
	
	// The only extra information needed for a SalariedEmployee.
	protected double salary;
	
	// Tax Rates for the Salaried Employees.
	final protected static double SS_RATE = .06;
	final protected static double LOW_TAX_RATE = .10;
	final protected static double MID_TAX_RATE = .15;
	final protected static double HIGH_TAX_RATE = .20;
	
	
	// Constructor sets all the instance variables based on the 
	// corresponding formal parameters.
	public SalariedEmployee(String f, String l, int daysv, double sal) {
		super(f, l, daysv);
		salary = sal;
	}
	
	// Returns the amount of tax withheld. If the salary is less than 
	// $25000, then 10% of the total salary is taken, otherwise if the
	// salary is less than $40000, 15% of the salary is taken. If the
	// salary is $40000 or more, 20% of the total salary is taken.
	public double taxwithheld() {
		
		if (salary < 25000)
			return LOW_TAX_RATE*salary;
		else if (salary < 40000)
			return MID_TAX_RATE*salary;
		else
			return HIGH_TAX_RATE*salary;
		
	}
	
	// Returns 6% of the total salary.
	public double sswithheld() {
		return salary*SS_RATE;
	}
	
	// Mature's the current object one year. In particular, five more
	// vacation days are added (with a cap of 30), and the salary is
	// increased by 5%.
	protected void mature() {
		daysofvacation += 5;
		salary *= (1.05);
		if (daysofvacation > 30)
			daysofvacation = 30;
	}
	
	// Prints out the current object's W2 form and matures the object one
	// year.
	public void printw2() {
		DecimalFormat twodec = new DecimalFormat("0.00");
		System.out.println("Employee's name: "+first+" "+last);
		System.out.println("Days of Vacation: "+daysofvacation);
		
		System.out.println("Wages,tips,other compensation: "+twodec.format(salary));
		System.out.println("Federal income tax withheld: "+twodec.format(taxwithheld()));
		System.out.println("Social security tax withheld: "+twodec.format(sswithheld()));
		
		mature();
		System.out.println();
	}
}