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

Using Java. Create a class called Employee. It will have 3 attribute fields. Id

ID: 3806901 • Letter: U

Question

Using Java. Create a class called Employee. It will have 3 attribute fields. Id as integer, and name as String. It will have setter methods. It will have a showEmployeeInfoMethod() as a void.

Create a class called HourlyEmployee that extends the Employee class.

It will have int as hours and rate as double. It will have setter methods and a a showEmployeeInfo() as a void that will display the employee name and id along with the employee hours and rate and calculated salary as hours times rate in “correct money format”

Create 1 object called e1 in a class called EmployeeTester

You will pass any values you want using all setter methods.

You will display the information for the Employee

Explanation / Answer

code:

class Employee
{
int id;
String name;
Employee(int i,String n)
{
id =i;
name =n;
}
void setid(int i)
{
id =i;
}
void setname(String n)
{
name=n;
}
void showEmployeeInfoMethod()
{
System.out.println("id: "+id);
System.out.println("name: "+name);
}
}

class HourlyEmployee extends Employee
{
int hours;
double rate;
HourlyEmployee(int i,String n,int h,double r)
{
super(i,n);
hours=h;
rate =r;
}
void showEmployeeInfoMethod()
{
System.out.println("id: "+id);
System.out.println("name: "+name);
double sal = hours*rate;
System.out.println("salary: "+sal);
}
}
public class HelloWorld{

public static void main(String []args){
HourlyEmployee ob = new HourlyEmployee(1,"ankit",1,1);
ob.showEmployeeInfoMethod();
}
}

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