NICCalculate.jsp
package com; import com.*; import com.EmployeeObject4; import java.util.*; import java.io.*; public class NICCalculate { static ArrayList NICvaribles; //Gives the value of the Lower Earnings Limit requires recording should the employees //wages reach it. static double LEL_LEL = 0.0; //LELxET Represents wages between the Lower Earning Limit and the Earning //Threshold static double LEL_ET = 0.0; //ETxUEL Represents wages between the Earning Limit and Upper Earning Limit static double ET_UEL = 0.0; //UELxUP Represents wages above the Upper Earning Limit static double UEL_UP = 0.0; //The NIC contributions for the employer and employee once calculated are //placed in these varibles. static double Employer; static double Employee; public void NICCalculate() { } public static void body(EmployeeObject4 employee) { double grossPay = employee.getGrossPay(); double LEL; double ET; double UEL; //If the pay period is weekly. if(employee.getMonthWeek().equals("weekly") ) { //The weekly values for the LEL the ET and the UEL are taken from the static methods of //InlandRevVar LEL = InlandRevVar.getLELweek(); ET = InlandRevVar.getETweek(); UEL = InlandRevVar.getUELweek(); } //If the pay period is monthly. else { //Monthly values are used. LEL = InlandRevVar.getLELmonth(); ET = InlandRevVar.getETmonth(); UEL = InlandRevVar.getUELweek(); } //The if statements below work out how much pay falls between the between the //different boundaries if(grossPay > LEL && grossPay < ET) { LEL_LEL = LEL; LEL_ET = grossPay - LEL; } if(grossPay > ET && grossPay < UEL) { LEL_LEL = LEL; LEL_ET = ET - LEL; ET_UEL = grossPay - ET; } if(grossPay > UEL) { LEL_LEL = LEL; LEL_ET = ET - LEL; ET_UEL = UEL - ET; UEL_UP = grossPay - UEL; } //From statis method getNICList of class InlandRevVar an ArrayList of the // the diiferent tables is taken different NIC percentages is taken and saved // as NICvaribles NICvaribles = InlandRevVar.getNICList(); //The NIC elements in the arrayList are in group of three the is a charecter //that represents the table two which the varibles belong the second represents //the percent which the employee pays on their wages that fall into the Bracket //in which NICs are paid. The third represents the percent the employer pays //The for loop runs throught the list until the relevant table letter for the //employee is found. for(int p = 0;p < NICvaribles.size();p = p+3) { if(NICvaribles.get(p).equals(employee.getNICtable())) { Employee = new Double(NICvaribles.get(p+1).toString()).doubleValue(); Employer = new Double(NICvaribles.get(p+2).toString()).doubleValue(); } } // divided by one hundred to make it a percent calculation employee.setNewEmployeeNICcont(ET_UEL * Employee/100); employee.setNewEmployerNICcont((ET_UEL + UEL_UP) * Employer/100); employee.setLEL_LEL(LEL_LEL); employee.setLEL_ET(LEL_ET); employee.setET_UEL(ET_UEL); } }