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

Write a program which will produce a report with the following requirements: 1.

ID: 3736323 • Letter: W

Question

Write a program which will produce a report with the following requirements: 1. Design classes: Employee, PartTime Employee and FullTime Employee classes as below. Employee -name: String id int Employee(String name, int id) +toString): String PartTime Employee -hours: double -hourlyWage : double PartTime Employee(String name, int id, double hours, double hourlyWage) +getSalary0: double +toStringO: String note: salary hours*hourlyWage FullTime Employee -salary: double FullTime Employee(String name, int id, double salary) +getSalary0: double +toString: String 2. Implement the toStringO methods for each class that will print the data fields(require: invoke 3. In xxxx_ Lab7 class (xxxx is your email ID): super.toString)). Write a main method which create one part-time employee object and one full-time employee object. a. b. Print these two object's information. (require: use toString0).

Explanation / Answer

Employee.java

public class Employee {
//Declaring instance variables
private int id;
private String name;

//Parameterized constructor
public Employee(int id, String name) {
super();
this.id = id;
this.name = name;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return " id=" + id + ", name=" + name;
}

}

_________________

PartTime_Employee.java

public class PartTime_Employee extends Employee {

//Declaring instance variables
private int hours;
private int hourlyWage;
//Parameterized constructor
public PartTime_Employee(int id, String name, int hours, int payPerHour) {
super(id, name);
this.hours = hours;
this.hourlyWage = payPerHour;
}

//Setters and getters
public int getHours() {
return hours;
}

public void setHours(int hours) {
this.hours = hours;
}

public int getHourlyWage() {
return hourlyWage;
}

public void setHourlyWage(int hourlyWage) {
this.hourlyWage = hourlyWage;
}


public double getSalary() {
return hourlyWage * hours;
}

//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return "PartTimeEmployee [" + super.toString() + " salary=" + getSalary() + "]";
}


}

__________________

FullTime_Employee.java

public class FullTime_Employee extends Employee {
//Declaring instance variables
private double salary;
//Parameterized constructor
public FullTime_Employee(int id, String name, double salary) {
super(id, name);
this.salary = salary;
}

public double getSalary() {
return salary;
}
//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return "FullTimeEmployee [" + super.toString() + " salary=" + salary + "]";
}

}

__________________

Test.java

public class Test {

public static void main(String[] args) {

//Declaring Employee Class Variables
Employee empPT, empFT;
//Creating an Instance of PartTimeEmployee Class
empPT = new PartTime_Employee(111, "Rahul", 40, 12);
//Creating an Instance of FullTimeEmployee Class
empFT = new FullTime_Employee(222, "John", 50000);
//Calling the toString() method
System.out.println(empPT);
System.out.println(empFT);

}

}

___________________

Output:

PartTimeEmployee [ id=111, name=Rahul salary=480.0]
FullTimeEmployee [ id=222, name=John salary=50000.0]

______________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote