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

1.Design a JAVA TEXTPAD program with a class named Payroll that contains the fol

ID: 3567017 • Letter: 1

Question

1.Design a JAVA TEXTPAD program with a class named Payroll that contains the following data fields, constructor and methods.

2.The data fields:

   A private String data field named name for the name of the employee.

    A private int data field named ID for the employees ID.

    A private double data field named payRate for the employees hourly pay rate.

    A private double data field named hrWorked for the employees worked hours.

    A private, static int data field named numberOfObjects for tracking the number of employees.

Add one more data field, dateCreated, which is object of java.util.Date, to thePayroll class, and one accessor method for this data field (use toString() method in the Date class).

3.The constructor and other methods:

    A constructor that accepts the employees name, ID, and pay rate as arguments. These values should be assigned to the objects name, ID, and payRate fields. The constructor should also update the numberOfObjects.

    The accessor (getter) and mutator (setter) methods for data field hrWorked (2 methods).

    The accessor (getter) methods for data fields name, ID, payRate, and numberOfObjects (4 methods).

    A method named grossPay that returns employees gross pay (=hrWorked * payRate).

5.Derive a subclasses named PayrollOvertime from the Payroll class with the additional members:

A private double data field named overtimePayRate for the employees overtime hourly pay rate.
A private double data field named overtimeHrWorked for the employees worked overtime hours.
The accessor (getter) method for data field overtimePayRate (only 1 method).
The accessor (getter) methods for data field overtimeHrWorked (2 methods).
Override the grossPay that returns employees gross pay

(=hrWorked * payRate+ overtimePayRate *overtimeHrWorked)

Use super key word to get the result for hrWorked * payRate

The constructor of the PayrollOvertime class accepts the employees name, ID, pay rate and overtime pay rate as arguments. These values should be assigned to the objects name, ID, payRate, and overtimePayRate data fields. The constructor should also update the numberOfObjects. (hint: use super ( ) to invoke the constructor ofPayroll class).

1.Design a JAVA TEXTPAD program with a class named Payroll that contains the following data fields, constructor and methods. 2.The data fields: A private String data field named name for the name of the employee. A private int data field named ID for the employees ID. A private double data field named payRate for the employees hourly pay rate. A private double data field named hrWorked for the employees worked hours. A private, static int data field named numberOfObjects for tracking the number of employees. Add one more data field, dateCreated, which is object of java.util.Date, to thePayroll class, and one accessor method for this data field (use toString() method in the Date class). 3.The constructor and other methods: A constructor that accepts the employees name, ID, and pay rate as arguments. These values should be assigned to the objects name, ID, and payRate fields. The constructor should also update the numberOfObjects. The accessor (getter) and mutator (setter) methods for data field hrWorked (2 methods). The accessor (getter) methods for data fields name, ID, payRate, and numberOfObjects (4 methods). A method named grossPay that returns employees gross pay (=hrWorked * payRate). 5.Derive a subclasses named PayrollOvertime from the Payroll class with the additional members: A private double data field named overtimePayRate for the employees overtime hourly pay rate. A private double data field named overtimeHrWorked for the employees worked overtime hours. The accessor (getter) method for data field overtimePayRate (only 1 method). The accessor (getter) methods for data field overtimeHrWorked (2 methods). Override the grossPay that returns employees gross pay (=hrWorked * payRate+ overtimePayRate *overtimeHrWorked) Use super key word to get the result for hrWorked * payRate The constructor of the PayrollOvertime class accepts the employees name, ID, pay rate and overtime pay rate as arguments. These values should be assigned to the objects name, ID, payRate, and overtimePayRate data fields. The constructor should also update the numberOfObjects. (hint: use super ( ) to invoke the constructor ofPayroll class). output should be as so:

Explanation / Answer

public class EmployeePayroll
    {
    private String firstName, lastName, id;
    private double hoursWorked, payRate, grossPay, netPay, tax;
    public EmployeePayroll()
    {
    firstName=""; lastName=""; id=""; hoursWorked=0; payRate=0;
    tax = 0.42; //fixed tax rate(42%)
    }//constructor
    public EmployeePayroll(String firstName, String lasName, String id, double hoursWorked, double payRate)
    {
    this.firstName=firstName; this.lastName=lastName; this.id=id; this.hoursWorked=hoursWorked; this.payRate=payRate;
    }//constructor
    public void set(String firstName, String lastName, String id, double hoursWorked, double payRate, double grossPay, double netPay)
    {
    this.firstName=firstName; this.lastName=lastName; this.id=id; this.hoursWorked=hoursWorked; this.payRate=payRate; this.grossPay=grossPay; this.netPay=netPay;
    }
    public void calcGrossPay()
    {
    if (hoursWorked <= 38)
    {
    grossPay = hoursWorked*payRate;
    }
    else if (hoursWorked <= 42)
    {
    grossPay = 38* payRate + (hoursWorked - 38) * 1.5 * payRate;
    }
    else if (hoursWorked <= 60)
    {
    grossPay = 38 * payRate + 4 * 1.5 * payRate + (hoursWorked - 42) * 2 * payRate;
    }
    else
    {
    grossPay=hoursWorked*payRate;
    }
    }//end if
    public void calcNetPay()
    {
    netPay=grossPay-(grossPay*tax);
    }
    public String GetFirstName()
    {
    return firstName;
    }
    public String GetLastName()
    {
    return lastName;
    }
    public double GetHoursWorked()
    {
    return hoursWorked;
    }
    public double GetHourlyPay()
    {
    return payRate;
    }
    public double GetGrossPay()
    {
    return grossPay;
    }
    public double GetNetPay()
    {
    return netPay;
    }
    public String GetId()
    {
    return id;
    }
    }