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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started