Answered Essay: Payroll System Using Inheritance and Polymorphism in Java

Payroll System Using Inheritance and Polymorphism in Java

1. Implement an interface called EmployeeInfo with the following constant variables:

FACULTY_MONTHLY_SALARY = 6000.00

STAFF_MONTHLY_HOURS_WORKED = 160

2. Implement an abstract class Employee with the following requirements:

Attributes

last name (String)

first name (String)

ID number (String)

Sex – M or F

Birth date – Use the Calendar Java class to create a date object

Default argument constructor and argument constructors.

Public methods

toString – returning a string with the following format:
ID Employee number :_________
Employee name: __________
Birth date: _______

mutators and accessors

abstract method monthlyEarning that returns the monthly earning.

3. Implement a class called Staff extending from the class Employee with the following requirements:

Attribute

Hourly rate

Default argument and argument contructors

Public methods

get and set

The method monthlyEarning returns monthly salary (hourly rate times 160)

toString – returning a string with the following format:
ID Employee number :_________
Employee name: __________
Birth date: _______
Full Time
Monthly Salary: _________

Implelment a class Education with the following requirements:

Attributes

Degree (MS or PhD )

Major (Engineering, Chemistry, English, etc … )

Research (number of researches)

Default argument and argument constructors.

Public methods

get and set

Implement a class Faculty extending from the class Employee with the following requirements:

Attributes

Level (Use enum Java)
“AS”: assistant professor
“AO”: associate professor
“FU”: professor

Education object

Default argument and argument constructor

Public methods

mutators and accessors

The method monthlyEarning returns monthly salary based on the faculty’s level.
AS – faculty monthly salary
AO – 1.5 times faculty monthly salary
FU – 2.0 times faculty monthly salary

toString – returning a string with the following format:
ID Employee number :_________
Employee name: __________
Birth date: _______
XXXXX Professor where XXXXX can be Assistant, Associate or Full
Monthly Salary: _________

Implement a class called Partime extending from the class Staff with the following requirements:

Attributes

Hours worked per week

Default argument and argument constructors

Public methods

mutators and accessors

The method monthlyEarning returns monthly salary . The monthly salary is equal to hourly rate times the hours worked in four weeks.

toString – returning a string with the following format:
ID Employee number :_________
Employee name: __________
Birth date: _______
Hours works per month: ______
Monthly Salary: _________

mplement a test driver program that creates a one-dimensional array of class Employee to store the objects Staff, Faculty and Partime.

Using polymorphism, display the following outputs:

a. Employee information using the method toString

Staff

Faculty

Part-time

b. Total monthly salary for all the part-time staff .
c. Total monthly salary for all employees.
d. Display all employee information descending by employee id using interface Comparable
e. Display all employee information ascending by last name using interface Comparer
f. Duplicate a faculty object using clone. Verify the duplication.

Test Data

Staff

Last name: Allen
First name: Paita
ID: 123
Sex: M
Birth date: 2/23/59
Hourly rate: $50.00

Last name: Zapata
First Name: Steven
ID: 456
Sex: F
Birth date: 7/12/64
Hourly rate: $35.00

Last name:Rios
First name:Enrique
ID: 789
Sex: M
Birth date: 6/2/70
Hourly rate: $40.00

Faculty

Last name: Johnson
First name: Anne
ID: 243
Sex: F
Birth date: 4/27/62
Level: Full
Degree: Ph.D
Major: Engineering
Reseach: 3

Last name: Bouris
First name: William
ID: 791
Sex: F
Birth date: 3/14/75
Level: Associate
Degree: Ph.D
Major: English
Reseach: 1

Last name: Andrade
First name: Christopher
ID: 623
Sex: F
Birth date: 5/22/80
Level: Assistant
Degree: MS
Major: Physical Education
Research: 0

Expert Answer

 

Payroll System Using Polymorphism

This section reexamines the CommissionEmployee-BasePlusCommissionEmployee hierarchy that we explored throughout Section 9.4. Now we use an abstract method and polymorphism to perform payroll calculations based on the type of employee. We create an enhanced employee hierarchy to solve the following problem:

  • A company pays its employees on a weekly basis. The employees are of four types: Salaried employees are paid a fixed weekly salary regardless of the number of hours worked, hourly employees are paid by the hour and receive overtime pay for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and salaried-commission employees receive a base salary plus a percentage of their sales. For the current pay period, the company has decided to reward salaried-commission employees by adding 10% to their base salaries. The company wants to implement a Java application that performs its payroll calculations polymorphically.

We use abstract class Employee to represent the general concept of an employee. The classes that extend Employee are SalariedEmployee, CommissionEmployee and HourlyEmployee. Class BasePlusCommissionEmployee—which extends CommissionEmployee—represents the last employee type. The UML class diagram in Fig. 10.2 shows the inheritance hierarchy for our polymorphic employee-payroll application. Note that abstract class Employee is italicized, as per the convention of the UML.

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?