Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

design an Employee class. Your Employee class should have the following data mem

ID: 3590015 • Letter: D

Question

design an Employee class. Your Employee class should have the following data members:

employeeNumber (integer)
name (string)
address (string)
phone (string)
hourlyWage (double)
hoursWorked this week (double)

Your Employee class will have the following functions:

A constructor for the Employee class that takes arguments to initialize all of the above mentioned data members.

'Getters' for each data attribute of your class.

Setters for every attribute except employeeNumber. We will not use the setters in this assignment, but in an actual payroll application, employee data, except for the employee number, can change (due to address change, marriage, a raise or promotion etc.).

A function, calcPay() that calculates and returns an employee's net pay. An employee's gross pay is calculated by multiplying the hours worked by their hourly wage. Be sure to give time-and-a-half for overtime (anything over 40 hours). To compute the net pay, deduct 20% of the gross for Federal income tax, and 7.5% of the gross for state income tax.

A function, printCheck() that prints out a pay check for each employee.

Explanation / Answer

package test1;

public class Employee {

private int employeeNumber;

private String name;

private String address;

private String phone;

private double hourlyWage;

private double hoursWorkedThisWeek;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public String getPhone() {

return phone;

}

public void setPhone(String phone) {

this.phone = phone;

}

public double getHourlyWage() {

return hourlyWage;

}

public void setHourlyWage(double hourlyWage) {

this.hourlyWage = hourlyWage;

}

public double getHoursWorkedThisWeek() {

return hoursWorkedThisWeek;

}

public void setHoursWorkedThisWeek(double hoursWorkedThisWeek) {

this.hoursWorkedThisWeek = hoursWorkedThisWeek;

}

public int getEmployeeNumber() {

return employeeNumber;

}

public void calcPay(){

double netPay;

if(hoursWorkedThisWeek>40){

netPay = (40*hourlyWage) + (hoursWorkedThisWeek-40)*1.5*hourlyWage;

}

else{

netPay = hoursWorkedThisWeek*hourlyWage;

}

//netPay after tax deductions

netPay = netPay - (0.20*netPay) - (0.075*netPay);

System.out.println("Net Pay for employee <"+getEmployeeNumber()+"> is : "+netPay);

}

public void printCheck(){

System.out.println("Printing check...");

}

public Employee(int employeeNumber, String name, String address, String phone, double hourlyWage, double hoursWorkedThisWeek){

this.employeeNumber = employeeNumber;

this.name = name;

this.address = address;

this.phone = phone;

this.hourlyWage = hourlyWage;

this.hoursWorkedThisWeek = hoursWorkedThisWeek;

}

public static void main(String[] args) {

// TODO Auto-generated method stub

Employee e = new Employee(111,"Pratik","Houston","12345678900",40.0,50);

e.calcPay();

}

}