Create a superclass class Employee with this:
-A name and salary instance variables
-A constructor that receives values to set the values of the instance variables
-To String method that returns the name along with the salary as a String
Create a class Manager that inherits from Employee with the following:
-Add an instance variable, named department, of type String.
-A constructor that receives the values of name, salary, and department and set them properly
-Supply a method toString that returns the manager’s name, department, and salary.
Create a class Executive that inherits from the Manager with the following:
-A constructor that receives the values of name, salary, and department and set them properly
-toString method that returns the manager’s name, department, and the salary he
Create a class that contains the main method with the following
-Create an object of each Employee, Manager, and Executive properly
-Display the returned value of calling the toString methods for each of the created objects
class Employee {
	// -A name and salary instance variables
	private String name;
	private double salary;
	public Employee() {
	}
	/**
	 * -A constructor that receives values to set the values of the instance
	 * variables
	 * 
	 * @param name
	 * @param salary
	 */
	public Employee(String name, double salary) {
		this.name = name;
		this.salary = salary;
	}
	/**
	 * -To String method that returns the name along with the salary as a String
	 */
	@Override
	public String toString() {
		return "Name: " + name + "\nSalary: " + salary + "\n";
	}
}
class Manager extends Employee {
	// -Add an instance variable, named department, of type String.
	private String namedDepartment;
	public Manager() {
	}
	/**
	 * -A constructor that receives values to set the values of the instance
	 * variables
	 * 
	 * @param name
	 * @param salary
	 * @param namedDepartment
	 */
	public Manager(String name, double salary, String namedDepartment) {
		super(name, salary);
		this.namedDepartment = namedDepartment;
	}
	/**
	 * -To String method that returns the name along with the salary as a String
	 */
	@Override
	public String toString() {
		return "Manager:\n" + super.toString() + "Department: " + namedDepartment + "\n\n";
	}
}
class Executive extends Manager {
	public Executive() {
	}
	public Executive(String name, double salary, String namedDepartment) {
		super(name, salary, namedDepartment);
	}
	/**
	 * -To String method that returns the name along with the salary as a String
	 */
	@Override
	public String toString() {
		return "Executive\n" + super.toString() + "\n\n";
	}
}
public class App {
	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Employee employees[] = new Employee[10];
		employees[0] = new Employee("Peter Smith", 4000);
		employees[1] = new Employee("Mary Smith", 4500);
		employees[2] = new Employee("Tony Stark", 3000);
		employees[3] = new Employee("Mike Tomson", 2000);
		employees[4] = new Manager("Mike Peterson", 4200, "IT");
		employees[5] = new Manager("Julia Clark", 3500, "Billing");
		employees[6] = new Manager("Denis Azimov", 2500, "Support");
		employees[7] = new Executive("Mary Peterson", 1200, "Department 5");
		employees[8] = new Executive("Julia Clark", 2500, "Department 8");
		employees[9] = new Executive("Denis Asi", 5500, "Department 45F");
		for (int i = 0; i < 10; i++) {
			System.out.println(employees[i].toString());
		}
	}
}
Comments