Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Payroll Calculations Inheritance Specification: A company pays its employees on a weekly basis. The employees are of 3 types: Salaried employees are paid a fixed

Payroll Calculations Inheritance Specification: A company pays its employees on a weekly basis. The employees are of 3 types: Salaried employees are paid a fixed weekly salary regardless of the hours worked, hourly employees are paid by the hour and receive overtime pay (1.5) for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales. This application is to calculate the payroll polymorphically. Create an abstract class named Employee which has three private members (lastName, firstName, and employeeID). Employee class contains one abstract method called earnings() (returns weekly pay) which will be implemented by its sub (derived) classes (SalariedEmployee, HourlyEmployee, and CommissionedEmployee). Besides inheriting from its base class, SalariedEmployee has weeklySalary field, HourlyEmployee has hourlyWage and hoursWorked fields, CommissionedEmployee has grossSales and commRate fields. Write constructors, getters/setters, toString() method for each class and implement earnings() method for each sub class. Use main class to test all classes and displays the employee information and weekly pay. Classes Design: You may add any additional variables and methods to implement the logic of your solution. Super Class: Employee Abstract Class Private data fields: employeeID:int read only, firstName:String, lastName:String Constructors: one parameterized constructor to set up the value for all private data fields Getter/Setter: employeeID is ready-only field, it has only the getter. Both names have getter and setter. Public methods: Method name Return type Parameter list and purpose getEmployeeId int ()->parameter list Return employee id getFirstName String ()->parameter list Return first name setFirstName void (String fName)->parameter list Set first name with fName getLastName String ()->parameter list Return last name setLastName void (String lName)->parameter list Set last name with lName earnings double ()->parameter list abstract method Calculates weekly pay for each employee type toString String ()->parameter list Return string contains employee id, first name and last name Sub Class: SalariedEmployee Private data fields: weeklySalary:double Constructors: one parameterized constructor to set up the value for all private data fields (call super classs constructor first before setting its own field) Getter/Setter: getter and setter for weeklySalary Methods: earnings() overrides earnings() calculates weekly pay by returning the weekly salary COSC 1437 Java Assignment 5 toString() returns employee info and pay, call super classs toString() method, plus its own info. Sub Class: HourlyEmployee Private data fields: hoursWorked:int, hourlyWage:double Constructors: one parameterized constructor to set up the value for all private data fields (call super classs constructor first before setting its own fields) Getter/Setter: getter and setter for hoursWorked and hourlyWage Methods: earnings() overrides earnings() - calculates weekly pay based on hours worked and hourly rate, needs to include overtime pay calculation toString() returns employee info and pay, call super classs toString() method, plus its own info. Sub Class: CommissionedEmployee Private data fields: grossSales:double, commRate:double Constructors: one parameterized constructor to set up the value for all private data fields (call super classs constructor first before setting its own fields) Getter/Setter: getter and setter for grossSales, commRate Methods: earnings() overrides earnings() - calculates weekly pay based on the gross sales and commission rate toString() returns employee info and pay, call super classs toString() method, plus its own info Assignment Instructions: 1. Create a NetBeans project and named it FirstName_LastName_A5 2. Create each separate java class file for Employee, SalariedEmployee, HourlyEmployee and CommissionedEmployee 3. In your main class, create instance for each sub class and print the result 4. Name your variables clearly 5. Add comments to document your project and code 6. Add space/indentation to make your code easier to read 7. Zip your assignment and submit it in Canvas for grading Program Output:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago