Question: Convert this payroll program into modular prgram. //Payroll.java //Employee Payroll of XYZ company import java.util.Scanner; //defining local class Employee class Employee { //instance variables private

Convert this payroll program into modular prgram.

//Payroll.java //Employee Payroll of XYZ company import java.util.Scanner; //defining local class Employee class Employee { //instance variables private String firstName; private String MI; private String lastName; private String ID; private int hours; private double rate; //Default constructor public Employee() { firstName=MI=lastName=ID="";//set empty string hours=0; rate=0.0; //set initial values } //Reading input values of Employee public void readEmployee() { Scanner input=new Scanner(System.in); //create scanner object //read all input instance variables System.out.println("Enter First Name : "); firstName=input.nextLine(); System.out.println("Enter MI : "); MI=input.nextLine(); System.out.println("Enter Last Name : "); lastName=input.nextLine(); System.out.println("Enter ID# : "); ID=input.nextLine(); System.out.println("Enter hours worked : "); hours=input.nextInt(); System.out.println("Enter Rate : "); rate=input.nextDouble(); } //Getter methods public String getFirstName() { return firstName;} public String getMI() { return MI;} public String getLastName() { return lastName;} public String getID() { return ID;} public int getHours() { return hours;} public double getRate() { return hours;} //Method print all details in string format @Override public String toString() { return firstName+"\t"+MI+"\t"+lastName+"\t"+ID+"\t"+hours+"\t"+rate; } } //Payroll class public class Payroll { //Executable main public static void main(String[] args) { double total; double gross=0,hGross=0,lGross=0; Employee[] employees=new Employee[10];//create 10 employees array System.out.println("Enter 10 employee records : "); for(int i=0;i<10;i++) //repeat 10 times { employees[i]=new Employee();//create each instance employees[i].readEmployee();//call read method } System.out.println("First Name MI Last Name ID# Hours Rate State Tax Fed Tax SS Tax Net"); for(int i=0;i<10;i++) { System.out.print(employees[i]);//print each employee record if(employees[i].getHours()<=40) //when hours worked is below 40 total=employees[i].getHours()*employees[i].getRate(); //calculate total wage else //when hours more than 40 total=(employees[i].getHours()*employees[i].getRate())+((employees[i].getHours()-40)*employees[i].getRate()*1.5); //calculate total wage double sTax=total*7/100; //state tax double fTax=total*14/100; //federal tax double ssTax=total*3/100; //ss Tax System.out.print("\t"+sTax+"\t"+fTax+"\t"+ssTax+"\t"+(total-(sTax+fTax+ssTax))+" ");//print calculated details gross+=total; if(hGross==0 || hGrosstotal) //compare and get lowest lGross=total; } //printing summary System.out.println("Total Gross : "+gross); System.out.println("Employee with highest gross amount "+hGross); System.out.println("Employee with lowest gross amount "+lGross); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!