A company pays its employees on a weekly basis. The employees are of four types: Salariedemployeesarepaidafixedweeklysalaryregardlessofthenumberofhoursworked, hourly employees are paid by the hour and receive overtime pay (i.e., 1.5 times their hourly salary rate) for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and base-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 write an application that performs its payroll calculations polymorphically. Create an EMPLOYEE class having First Name, Last Name, socialSecurityNumber(SSN); Provide a default Constructor. Provide overloaded parameterized Constructors. Provide getters, and setters for the data members. In addition there is method earnings which will return the earning of employees. For now you just simply prints a statement “calculate salary”. Class SalariedEmployee extends class Employee having weeklySalary as a member and overrides method earnings. The class includes a constructor that takes a first name, a last name, a social security number and a weekly salary as arguments; a set method to assign a new non negative value to instance variable weeklySalary; a get method to return weeklySalary; a method earnings to calculate a SalariedEmployee’s earnings; and a method toString, which returns a String including the employee’s type, name and SSN. Class HourlyEmployee also extends Employee and have hourlyWage and hoursWorked as data members. The class includes a constructor that takes as arguments a first name, a last name, a social security number, an hourlyWage and the hoursWorked. Declare set method s that assign new values to instance variables wage and hours, respectively. Method setWage ensures that wage is non negative, and method setHours ensures that hours is between 0 and 168 (the total number of hours in a week) inclusive.  Class HourlyEmployee also includes get methods to return the values of wage and hours, respectively; a method earnings to calculate an HourlyEmployee’s earnings; and a method toString, which returns a String containing the employee’s type ("hourly employee: ")and the employee-specific information. The HourlyEmployee constructor, like the SalariedEmployee constructor, passes the first name, last name and social security number. Class CommissionEmployee having commissionRate and grossSales as data members extends class Employee.  The class includes a constructor that takes a first name, a last name, a social security number, a sales amount and a commission rate. The constructor also passes the first name, last name and SSN along with its own data members. Class have set methods to assign new values to instance variables commissionRate and grossSales, respectively, get methods that retrieve the values of these instance variables; an override method earnings to calculate a CommissionEmployee’s earnings; and method toString which returns the employee’s type, namely, "commission employee: " and employee-specific information. To test our Employee hierarchy, the application. Creates an object of each of the three classes SalariedEmployee, HourlyEmployee, CommissionEmployee. The program manipulates these objects non polymorphically, via variables of each object’s own type.  Then using polymorphically, an array of Employee type will be created having each type of employee as at each index of array. E.g. employees[ 0 ] = salariedEmployee;  employees[ 1 ] = hourlyEmployee;  employees[ 2 ] = commissionEmployee  Finally, the program polymorphically determines and outputs the type of each object, its earnings and other details in the Employee array.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

A company pays its employees on a weekly basis. The employees are of four types: Salariedemployeesarepaidafixedweeklysalaryregardlessofthenumberofhoursworked, hourly employees are paid by the hour and receive overtime pay (i.e., 1.5 times their hourly salary rate) for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and base-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 write an application that performs its payroll calculations polymorphically.

Create an EMPLOYEE class having First Name, Last Name, socialSecurityNumber(SSN);

  1. Provide a default Constructor.
  2. Provide overloaded parameterized Constructors.
  3. Provide getters, and setters for the data members.
  4. In addition there is method earnings which will return the earning of employees. For now you just simply prints a statement “calculate salary”.

Class SalariedEmployee extends class Employee having weeklySalary as a member and overrides method earnings. The class includes a constructor that takes a first name, a last name, a social security number and a weekly salary as arguments; a set method to assign a new non negative value to instance variable weeklySalary; a get method to return weeklySalary; a method earnings to calculate a SalariedEmployee’s earnings; and a method toString, which returns a String including the employee’s type, name and SSN.

Class HourlyEmployee also extends Employee and have hourlyWage and hoursWorked as data members. The class includes a constructor that takes as arguments a first name, a last name, a social security number, an hourlyWage and the hoursWorked. Declare set method s that assign new values to instance variables wage and hours, respectively. Method setWage ensures that wage is non negative, and method setHours ensures that hours is between 0 and 168 (the total number of hours in a week) inclusive.

 Class HourlyEmployee also includes get methods to return the values of wage and hours, respectively; a method earnings to calculate an HourlyEmployee’s earnings; and a method toString, which returns a String containing the employee’s type ("hourly employee: ")and the employee-specific information. The HourlyEmployee constructor, like the SalariedEmployee constructor, passes the first name, last name and social security number.

Class CommissionEmployee having commissionRate and grossSales as data members extends class Employee.

 The class includes a constructor that takes a first name, a last name, a social security number, a sales amount and a commission rate. The constructor also passes the first name, last name and SSN along with its own data members.

Class have set methods to assign new values to instance variables commissionRate and grossSales, respectively, get methods that retrieve the values of these instance variables; an override method earnings to calculate a CommissionEmployee’s earnings; and method toString which returns the employee’s type, namely, "commission employee: " and employee-specific information.

To test our Employee hierarchy, the application.

Creates an object of each of the three classes SalariedEmployee, HourlyEmployee, CommissionEmployee. The program manipulates these objects non polymorphically, via variables of each object’s own type.

 Then using polymorphically, an array of Employee type will be created having each type of employee as at each index of array. E.g.

employees[ 0 ] = salariedEmployee;

 employees[ 1 ] = hourlyEmployee;

 employees[ 2 ] = commissionEmployee

 Finally, the program polymorphically determines and outputs the type of each object, its earnings and other details in the Employee array.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 15 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY