Part 1 Implement a superclass Employee that has the followin

Part 1: Implement a superclass Employee that has the following fields and methods. Fields: String firstName String lastName int employeeID double salary Methods: Constructor(): initialize balance field to null and zero. Setters and getters for firstName, lastName, and employeeID EmployeeSummary() – prints all account attributes Part 2: Implement a Manager class that inherits from the Employee class. Has a department attribute Methods: EmployeeSummary() – prints all superclass and subclass attributes Ensure that your program has the two required classes and a test class. Submit screenshots of your program’s execution and output. Include all appropriate source code in a zip file.

Solution

import java.util.*;
import java.lang.*;
import java.io.*;

class Employee
{
//attributes of Employee class
private String firstName;
private String lastName;
private int employeeID;
private double salary;
public Employee()                          //default constructor
{
  firstName=null;
  lastName=null;
  employeeID=0;
  salary=0.0;
  
}
public void setFirstName(String fname)       //set and get methods for all attributes
{
  firstName = fname;
}
public String getFirstname()
{
  return firstName;
}
public void setLastName(String lname)
{
  lastName = lname;
}
public String getLastName()
{
  return lastName;
}
public void setEmployeeID(int empId)
{
  employeeID = empId;
  
}
public double getEmployeeID()
{
  return employeeID;
}
public void setSalary(double s)
{
  salary=s;
}
public double getSalary()
{
  return salary;
}
public void EmployeeSummary()       //display all attributes of Employee class
{
  System.out.println(\"Employee Name: \"+ firstName +\" \" +lastName+\" Employee Id : \"+employeeID + \" salary: \"+salary);
}
}
class Manager extends Employee          
{
private String department;
public Manager()                       //default constructor
{
  super();                           //calling superor base class default constructor
  department = null;
}
public void setDepartment(String dept)        //set and get methods for department
{
  department=dept;
}
public String getDepartment()
{
  return department;
}
public void EmployeeSummary()
{
  super.EmployeeSummary();     //calling super class method with same name
  System.out.println(\"Department : \"+department);
}
}

class TestEmployee
{
public static void main (String[] args)
{
  Manager mgr=new Manager();
  mgr.setFirstName(\"Charles\");        //all set methods of super class are available to derived class
  mgr.setLastName(\"Dickens\");
  mgr.setEmployeeID(34599);
  mgr.setSalary(6500);
  mgr.setDepartment(\"Accounts\");
  mgr.EmployeeSummary();

}
}

Output:

Success time: 0.04 memory: 711168 signal:0

Part 1: Implement a superclass Employee that has the following fields and methods. Fields: String firstName String lastName int employeeID double salary Methods
Part 1: Implement a superclass Employee that has the following fields and methods. Fields: String firstName String lastName int employeeID double salary Methods

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site