Question: I need help in JAVA' Write a class Employee with a name and salary. Have (at least) getters for name and salary. Whether you have

I need help in JAVA'

Write a class Employee with a name and salary. Have (at least) getters for name and salary. Whether you have setters or some other mechanism to set name and salary is up to you.

Make a class Manager inherit from Employee. Add an instance variable department of type String.

Make a class Executive inherit from Manager. Executive salaries are calculated differently the Employee or Manager salaries. An Executive's salary is the sum of the salary he (or she) gets as an Employee, plus a bonus. The bonus is expressed as a ratio that is multiplied by the Executive's Employee salary. For example, if an Executive's base salary (i.e., the salary as an Employee) is $230,000, and the Executive has a bonus of 0.2, the Executive's (true) salary would be $230,000 + $230,000 * 0.2. Executive should have a getSalary method.

Supply toString methods for all classes.

All instance variables must be (as usual) private.

Supply a test program that test all classes and methods. The tests should include (but not be limited to) tests such as

Employee dilbert = new Employee(...

System.out.println(dilbert);

Employee pointyHairedBoss = new Manager(...

System.out.println(pointyHairedBoss );

Employee clueless = new Executive(...

System.out.println(clueless);

Which toString method is called in each of these cases?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!