Question
Please write this code in Java perferably for Swift: Consider the Company class and the program output given. Now, design a class hierarchy that implements
Please write this code in Java perferably for Swift:
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 empList= new ArrayList(); monthlyPaidEmp mpE1 = new monthlyPaidEmp("John William" , 55675.00);
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
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