Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ArrayList CANNOT be used in this program. Please DO NOT use any Java collections/containers. I need the manager class public class Manager extends Employee without

ArrayList CANNOT be used in this program. Please DO NOT use any Java collections/containers. I need the manager class "public class Manager extends Employee" without the use of ArrayList, please no collections or containers. It all has to be done through binary search.

Define an Employee class. An Employee has a name, an ID number, an age, a salary, a title, and a department name. The methods of Employee should: a. Print an employee record that includes all of the above information b. Change a salary, changeSalary(), and c. return the salary, getSalary(). The method changeSalary() accepts a parameter, increase, of type int or double. If increase is an int, then the salary should be increased by that amount. If increase is double, then the new salary should be (increase + 1) times the salary. For example, if the increase is 0.10, the salary is multiplied by 1.10, yielding an increase of 10%. The value of the (double) increase should be between 0.0 and 1.0.

Define a class Manager that Extends Employee. A manager is an employee who supervises other employees. A Manager object should include all data of the Employee object plus the list of the employee ID numbers of those employees under his/her supervision as well as all the other relevant data.

Define a class Executive that extends Manager. An Executive is a Manager who receives a bonus a the end of each year equal to percentage of his/her regular salary. Each Executive has his/her own bonus rate. You will need to redefine getSalary() to include the bonus. You will also need to add a setter (mutator) method, setBonus(), to set the percentage of the executives bonus. The default bonus rate should be 10%.

Implement a test class that demonstrates the facilities of the Employee, Manager, and Executive classes. Your test class should accept employee information for an arbitrary number of employees. Your program should ask whether or not the employee is a manager or an executive, and prompt for all relevant information.

After all data are entered, print an error message if there are any inconsistencies. In particular, a manager cannot manage a nonexistent employee. Also, every employee who is not an executive is supervised by some manager or executive. Your program should provide the user with the following options:

Change the salary of an employee

Adjust the bonus of an executive

Add or delete an employee from a managers list of employees

Print an employees data

Employee

public class Employee

{

private String name;

private int id;

private int age;

private double salary;

private String title;

private String depName;

public Employee(int id, String name, int age, double salary, String title, String depName)

{

this.name = name;

this.id = id;

this.age = age;

this.salary = salary;

this.title = title;

this.depName = depName;

}

public void printEmployee() //Print Method

{

System.out.println("Employee Details Name: " + this.name);

System.out.println("ID: " + this.id);

System.out.println("Age: " + this.age);

System.out.println("Salary: " + this.salary);

System.out.println("Title: " + this.title);

System.out.println("Department Name: " + this.depName);

System.out.println();

}

public int findEmployee(Employee[] employees, String name) {

for (int index =0; index

Employee employeeTemp = employees[index];

String employeeName = employeeTemp.getName();

if(employeeName.equals(name)) {

return index;

}

}

return -1;

}

public void changeSalary(int inc) //Salary Method

{

this.salary = salary + inc;

}

public void changeSalary(double inc) throws Exception

{

if(inc >= 0 && inc

{

this.salary = (inc + 1) * salary;

}

else

{

throw new Exception("Increment should be in the range of 0.0 to 1.0");

}

}

public double getSalary()

{

return this.salary;

}

}

Executive

public class Executive extends Manager

{

private double bonus;

public Executive(int id, String name, int age, double salary, String title, String depName, double bonus)

{

super(id, name, age, salary, title, depName);

this.bonus = bonus;

}

public void setBonus(double bonus)

{

if(bonus >= 0 && bonus

{

this.bonus = bonus;

}

else

{

System.out.println("This bonus rate is invalid");

}

}

@Override

public double getSalary()

{

return this.getSalary() + this.getSalary() * (1 + bonus);

}

}

useEmployee

public class useEmployee

{

public static void main(String[] args)

{

Employee[] employees = new Employee[100];

employees[0] = new Employee(6120, "Anthony, Susan B.", 37, 360000.00, "MTS 3", "Engineers");

employees[1] = new Manager(1215, "Deleon, Amanda", 53, 225000.00, "Manager Level 3", "Research and Development");

employees[2] = new Executive(2, "Rothschild, Baron", 79, 500000.00, "Chairman", "Engineers", 0.15);

employees[3] = new Employee(8978, "Rothschild, Tyron", 23, 42000.00, "MTS 1", "Engineers");

employees[4] = new Employee(5950, "Yates, Fred", 37, 360000.00, "MTS 3", "Scientists");

((Manager)(employees[1])).addEmployee(employees[0]);

((Manager)(employees[1])).addEmployee(employees[3]);

((Manager)(employees[1])).addEmployee(employees[4]);

System.out.println("Amanda's direct reports: ");

((Manager)(employees[1])).printEmployeeList(); // why not use toString() here?

System.out.println(" --- All Employees --- ");

// employees[0].changeSalary(employees, 8978, 25000); ** OLD STYLE ** Why is this not optimal?

int index = employees[0].findEmployee(employees, "Rothschild, Tyron"); // Be sure this line is understood!

employees[index].changeSalary(25000);

int i = 0;

while (employees[i] != null)

System.out.println(employees[i++]);

}

public static int findEmployee()

{

}

}

image text in transcribed

image text in transcribed

Sample run: Amanda's direct reports: Anthony, Susan B. 6120 37 360000.0 MTS 3 Engineers Rothschild, Tyrorn 8978 23 42000.0 MTS 1 Engineer:s Yates, Fred 5950 37 360000.0 MTS 3 Scientists Sample run: Amanda's direct reports: Anthony, Susan B. 6120 37 360000.0 MTS 3 Engineers Rothschild, Tyrorn 8978 23 42000.0 MTS 1 Engineer:s Yates, Fred 5950 37 360000.0 MTS 3 Scientists

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

=+2. Explain the interactions in the newspaper and magazine market!

Answered: 1 week ago