Question: Please write in JAVA ( inheritance) Consider the Company class and the program output given. Now, design a class hierarchy that implements company employees salary
Please write in JAVA (inheritance)
Consider the Company class and the program output given. Now, design a class hierarchy that implements company employees salary calculation. A company has two types of employees: hourly paid employees and monthly salary based employees. Every employee has a name, salary and tax rate.
In addition, hourly paid employee has two attributes: hours worked and the hourly rate. The monthly paid employee has one attribute, annual salary. Both classes have constructor methods that take all attributes and a method to calculate monthly salary.
Finally both classes should have the toString method that returns name, monthly salary, and the tax paid
import java.util.ArrayList; public class Company { public static void main(String[] args) { ArrayList
monthlyPaidEmp mpE2 = new monthlyPaidEmp("Nancy William" , 65675.00); hourlyPaidEmp hpE1 = new hourlyPaidEmp("Samira Monid", 7.50, 35);
empList.add(mpE1); empList.add(mpE2); empList.add(hpE1);
for(int i=0; i Employee e= empList.get(i); e.calculateSalary(); empList.set(i,e);}
for(int i=0; i}
} }
System.out.println(empList.get(i));
a) Draw the UML class diagram that represents the above class hierarchy b) Implement the classes in your UML diagram above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
