Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Define an abstract super class called Employee that contains a name (String), a social security number (String) and the respective accessor and mutator


imageimage

1. Define an abstract super class called Employee that contains a name (String), a social security number (String) and the respective accessor and mutator functions. Include a two-parameter constructor. It should also contain a toString method whose task is to return the employee's name and social security number (in that order) and an equals method (two employees are equal if they have the same social security number, regardless of type). The Employee class should also declare an abstract getCalculatedSalary method which will be used to calculate the total salary in the derived classes. 2. Next, derive a class called HourlyEmployee to store two data members the hourly rate (double) and the number of hours (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the overtime amount. The overtime is calculated when an employee works more than 40 hours, the extra hours (>40) are paid at one and one half times the employee's regular hourly rate. Include a toString function that must return a String containing the name, social security number, hourly rate, hours, overtime amount and total weekly salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 3. Next, derive a class called Salaried Employee to store two data members: the bonus rate (double) and the yearly salary (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the bonus amount based on the bonus percentage and the yearly salary. Include a toString function that must return a String containing the name, social security number, bonus rate, base salary, bonus amount and total annual salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 4. In order to hold all employees, create a class called EmployeeList that is able to hold any number of Employees references. EmployeeList should have an ArrayList of Employee as its data member. Create a method to provide the capability to add an employee. An employee must not be added if it has a duplicate social security number. Display an error message if a duplicate is found. Please see example of the error message below: ERROR - Employee Not Added: (display the name of the employee) Duplicate SSN: (display the duplicate SSN). Include a toString function that displays the total number of employees on the list like the following: There are (number of employees) employees on the list It should also display the entire Employee List. Please include the data formatting as displayed on the sample output. Sample Output with sample data: ERROR - Employee Not Added: John Duplicate SSN: 111-00-0000 There are 2 employees on the list. Name: Albert SSN: 111-00-0000 Hourly Rate: $10.50 Hours: 40.00 Overtime Amount: $0.00 Total Weekly Salary: $420.00 Name: Peter SSN: 222-00-0000 Bonus Rate: 10% Base Salary: $50,000.00 Bonus Amount: $5,000.00 Total Annual Salary: $55,000.00 You must use the provided data on the main method. Please DO NOT CHANGE THE MAIN METHOD All classes, methods, calculations and data elements must be properly documented as discussed in class. Please use the main method for the main class below: public class Asg4YourName { } public static void main(String[] args) { } EmployeeListr = new EmployeeList(); r.add(new Hourly Employee("Jim", "400-00-0000", 15.60, 50)); r.add(new Salaried Employee("Alex", "500-00-0000", 81090, .05)); r.add(new Salaried Employee("Tim", "700-00-0000", 111577, .08)); r.add(new Hourly Employee("Mark", "600-00-0000", 21.75, 60)); r.add(new Hourly Employee("Bill", "100-00-0000", 30.00, 45)); r.add(new SalariedEmployee ("Bob", "200-00-0000", 61090, 02)); r.add(new Salaried Employee("Joe", "300-00-0000", 31690, .10)); r.add(new Hourly Employee("Jane", "700-00-0000", 25.50, 60)); r.add(new HourlyEmployee("Emma", "800-00-0000", 12.50, 30)); System.out.println(r);

Step by Step Solution

3.57 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Here is the implementation of the classes and methods as per the requirements provided 1 Employee class java public abstract class Employee private St... 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

Step: 3

blur-text-image

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Define Administration?

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago