Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use the code below JAVA Implement a subclass called Executive. Executive extends Manager, but an Executive only supervises an Employee who is a manager

please use the code below JAVA Implement a subclass called Executive. Executive extends Manager, but an Executive only supervises an Employee who is a manager An Executive ID number ranges from 3001 to 3500.

Create an additional instance variable of type double called totalComp for an Executive which may be initialized to 0.0.

Add a mutator method called setTotalComp with the companys profits and the bonus percentage as input values, which calculates and sets the total compensation of salary plus bonus as a double. An executive gets a bonus at the end of each year equal to a percentage of company profits.

Also include a getTotalComp() method which returns the totalComp. Modify the toString() method to include the totalComp.

Override toString to include the totalComp for the Executive. Also change the word in the printout from manager to executive.

import java.util.ArrayList; public class Manager { private String name; private int age; private double salary; private String title; private int managerId; private ArrayListmanagedEmployees; /*Manager constructor that takes name,age, salary and title*/ public Manager(String tName, int tAge, double tSalary, String tTitle) { name = tName; //Generate random number in a range of 2001 to 3000 managerId=(int)(Math.random()*1000+2000); age = tAge; salary = tSalary; title = tTitle; //instance of the ArrayList of Employee class managedEmployees=new ArrayList(); } public void addEmployee(Employee emp) { managedEmployees.add(emp); } public int getManagedEmployeesListSize() { return managedEmployees.size(); } public Employee getManagedEmployee(int index) { return managedEmployees.get(index); } public String toString() { return "Manager [name=" + name + ", Id=" + managerId + ", age=" + age + ", salary=" + salary + ", title=" + title + "]"; } }

........................................................

public class Employee { private String name; private int Id; private int age; private double salary; private String title; public Employee(String tName, int tId, int tAge, double tSalary, String tTitle) { //super(); name = tName; Id = tId; age = tAge; salary = tSalary; title = tTitle; }

public String getName() { return name; } public int getId() { return Id; } public int getAge() { return age; } public double getSalary() { return salary; } public String getTitle() { return title; } public void setName(String tName) { name = tName; } public void setId(int tId) { Id = tId; } public void setAge(int tAge) { age = tAge; } public void setSalary(double tSalary) { salary = tSalary; } public void setTitle(String tTitle) { title = tTitle; } public void changeSalary(double percentage) { salary=salary *(1+percentage/100); } public String toString() { return "Employee [name=" + name + ", Id=" + Id + ", age=" + age + ", salary=" + salary + ", title=" + title + "]"; } }/

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_2

Step: 3

blur-text-image_3

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions