TaxTables.class
//This class calculates owed from the pay sent. package com; import java.io.*; import com.InlandRevVar; import com.EmployeeObject4; public class TaxTables { static double lowerBoundary = 0.00; static double upperBoundary = 0.00; static double startingRate = 0.00; static double basicRate = 0.0; static double higherRate = 0.0; static double tax; public TaxTables() { } public static synchronized double getTax(double pay, EmployeeObject4 employee) { double period = employee.getCurrentPeriod(); String monthweek = employee.getMonthWeek(); lowerBoundary = InlandRevVar.getLowerBoundary(); upperBoundary = InlandRevVar.getUpperBoundary(); startingRate = InlandRevVar.getStartingRate(); basicRate = InlandRevVar.getBasicRate(); higherRate = InlandRevVar.getHigherRate(); double upBoundary; double lowBoundary; double periodNumber = 12; //Calculates what the taxBoundaries are for the curentperiod if(monthweek.equals("weekly")) { periodNumber = 52; } upBoundary = (upperBoundary/periodNumber)*period; lowBoundary = (lowerBoundary/periodNumber)*period; //Finds which boundary the pay lies between and carries out the relevant tax calculation. if(pay < lowBoundary ) { tax = pay * startingRate/100; } if(pay >lowBoundary && pay < upBoundary) { tax = (lowBoundary * startingRate/100)+((pay - lowBoundary)*basicRate/100); } if (pay > upBoundary) { tax = (lowBoundary * startingRate/100)+((upBoundary-lowBoundary)*basicRate/100)+(pay - upBoundary)*higherRate/100; } return tax; } }