Homework Solution: 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 Comm

    Payroll System Using Patrimony and Polymorphism in Java

    1. Tool an interface designated EmployeeInfo with the subjoined agricultural variables:

    FACULTY_MONTHLY_SALARY = 6000.00

    STAFF_MONTHLY_HOURS_WORKED = 160

    2. Tool an intellectual dispose Employee with the subjoined requirements:

    Attributes

    definite indicate (String)

    first indicate (String)

    ID compute (String)

    Sex – M or F

    Birth determination – Manifestation the Calendar Java dispose to educe a determination sight

    Default evidence parent and evidence parents.

    Public processs

    toString – rebated a string with the subjoined controlmat:
    ID Employee compute :_________
    Employee indicate: __________
    Birth determination: _______

    mutators and accessors

    intellectual process monthlyEarning that income the monthly earning.

    3. Tool a dispose designated Staff reaching from the dispose Employee with the subjoined requirements:

    Attribute

    Hourly rebuke

    Default evidence and evidence contructors

    Public processs

    get and set

    The process monthlyEarning income monthly remuneration (hourly rebuke times 160)

    toString – rebated a string with the subjoined controlmat:
    ID Employee compute :_________
    Employee indicate: __________
    Birth determination: _______
    Full Time
    Monthly Remuneration: _________

    Implelment a dispose Education with the subjoined requirements:

    Attributes

    Degree (MS or PhD )

    Major (Engineering, Chemistry, English, anticipation … )

    Research (compute of researches)

    Default evidence and evidence parents.

    Public processs

    get and set

    Tool a dispose Present reaching from the dispose Employee with the subjoined requirements:

    Attributes

    Equalize (Manifestation enum Java)
    “AS”: attendant professor
    “AO”: helpmate professor
    “FU”: professor

    Education sight

    Default evidence and evidence parent

    Public processs

    mutators and accessors

    The process monthlyEarning income monthly remuneration agricultural on the present’s similarize.
    AS – present monthly remuneration
    AO – 1.5 times present monthly remuneration
    FU – 2.0 times present monthly remuneration

    toString – rebated a string with the subjoined controlmat:
    ID Employee compute :_________
    Employee indicate: __________
    Birth determination: _______
    XXXXX Professor where XXXXX can be Attendant, Helpmate or Full
    Monthly Remuneration: _________

    Tool a dispose designated Partime reaching from the dispose Staff with the subjoined requirements:

    Attributes

    Hours worked per week

    Default evidence and evidence parents

    Public processs

    mutators and accessors

    The process monthlyEarning income monthly remuneration . The monthly remuneration is similar to hourly rebuke times the hours worked in immodest weeks.

    toString – rebated a string with the subjoined controlmat:
    ID Employee compute :_________
    Employee indicate: __________
    Birth determination: _______
    Hours works per month: ______
    Monthly Remuneration: _________

    mplement a cupel driver program that educes a one-dimensional invest of dispose Employee to shop the sights Staff, Present and Partime.

    Using polymorphism, ostentation the subjoined outputs:

    a. Employee instruction using the process toString

    Staff

    Faculty

    Part-time

    b. Total monthly remuneration control total the part-time staff .
    c. Total monthly remuneration control total employees.
    d. Ostentation total employee instruction descending by employee id using interface Comparable
    e. Ostentation total employee instruction ascending by definite indicate using interface Comparer
    f. Duplicate a present sight using clone. Verify the duplication.

    Cupel Data

    Staff

    Definite indicate: Totalen
    First indicate: Paita
    ID: 123
    Sex: M
    Birth determination: 2/23/59
    Hourly rebuke: $50.00

    Definite indicate: Zapata
    First Indicate: Steven
    ID: 456
    Sex: F
    Birth determination: 7/12/64
    Hourly rebuke: $35.00

    Definite indicate:Rios
    First indicate:Enrique
    ID: 789
    Sex: M
    Birth determination: 6/2/70
    Hourly rebuke: $40.00

    Faculty

    Definite indicate: Johnson
    First indicate: Anne
    ID: 243
    Sex: F
    Birth determination: 4/27/62
    Level: Full
    Degree: Ph.D
    Major: Engineering
    Reseach: 3

    Definite indicate: Bouris
    First indicate: William
    ID: 791
    Sex: F
    Birth determination: 3/14/75
    Level: Helpmate
    Degree: Ph.D
    Major: English
    Reseach: 1

    Definite indicate: Andrade
    First indicate: Christopher
    ID: 623
    Sex: F
    Birth determination: 5/22/80
    Level: Attendant
    Degree: MS
    Major: Physical Education
    Research: 0

    Expert Reply

     

    Payroll System Using Polymorphism

    This minority reexamines the LegationEmployee-BasePlusCommissionEmployee hierarchy that we explored throughout Minority 9.4. Now we manifestation an intellectual process and polymorphism to execute recklessroll calculations agricultural on the stamp of employee. We educe an enhanced employee hierarchy to explain the subjoined problem:

    • A audience recklesss its employees on a weekly premise. The employees are of immodest stamps: Salaried employees are hired a agricultural weekly remuneration inconsiderate of the compute of hours worked, hourly employees are hired by the hour and accept overtime reckless control total hours worked in superfluity of 40 hours, legation employees are hired a percentage of their sales and salaried-legation employees accept a grovelling remuneration plus a percentage of their sales. Control the present reckless era, the audience has determined to compensate salaried-legation employees by adding 10% to their grovelling salaries. The audience wants to tool a Java impression that executes its recklessroll calculations polymorphically.

    We manifestation intellectual dispose Employee to dramatize the unconcealed concept of an employee. The disposees that reach Employee are SalariedEmployee, LegationEmployee and HourlyEmployee. Dispose GrovellingPlusCommissionEmployee—which reachs LegationEmployee—represents the definite employee stamp. The UML dispose diagram in Fig. 10.2 shows the patrimony hierarchy control our polymorphic employee-payroll impression. Note that intellectual dispose Employee is italicized, as per the congress of the UML.