Exercise: I 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 (1.5* wage) for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and base-commission employees receive a base salary plus a commission based on their gross sales. The company wants to implement a Java application that performs its payroll calculations polymorphically. (50 points) Hint: This programming exercise is similar to the AbstractClassExample posted in Blackboard under chapter 10. SalariedEmployee Employee Class Commission Employee BasePlusCommission Employee HourlyEmployee

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter6: Managing Multiple Worksheets And Workbooks
Section: Chapter Questions
Problem 4.4CP
icon
Related questions
Question

Use NetBeans

Note for all the above User-Defined Classes:

• Provide appropriate validation code so the right values get populated in the instance variables. For example, the payrate should not be negative.

Write a Java application (Client) program with a static method called generateEmployees( ) that returns a random list of 10 different types of Employee objects. You would use an ArrayList to store the employee objects that will be returned. Use a for loop to populate randomly different types of employee objects with some random data. You could possibly think of a range of values like 1 – 4. If random value is 1, create a HourlyEmployee object with some randomly generated data, if 2, a SalariedEmployee object with some random data and so on. I would leave it to your ingenuity to generate and populate these different Employee objects with other data like name etc. As these objects are generated, add them to your data structure (array or ArrayList that you are using). Finally, the method returns this ArrayList In the same application class, implement the main( ) method. Call the generateEmployees( ) static method and using a for loop to print the details of each of the employee along with their earnings on the output window.

Exercise: I
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 (1.5 * wage) for all hours worked in excess of 40 hours, commission
employees are paid a percentage of their sales and base-commission employees receive a base salary
plus a commission based on their gross sales. The company wants to implement a Java application that
performs its payroll calculations polymorphically. (50 points)
Hint: This programming exercise is similar to the AbstractClassExample posted in Blackboard under
chapter 10.
SalariedEmployee
Employee Class
Commission Employee
BasePlusCommission Employee
Employee hierarchy UML Class diagram
HourlyEmployee
Transcribed Image Text:Exercise: I 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 (1.5 * wage) for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and base-commission employees receive a base salary plus a commission based on their gross sales. The company wants to implement a Java application that performs its payroll calculations polymorphically. (50 points) Hint: This programming exercise is similar to the AbstractClassExample posted in Blackboard under chapter 10. SalariedEmployee Employee Class Commission Employee BasePlusCommission Employee Employee hierarchy UML Class diagram HourlyEmployee
1. Write an Abstract Java class - Employee that encapsulates an employee's first name, last name,
SSN. Implement the appropriate get and set methods along with toString() method and
equals() method. Note: An abstract class is a class that cannot be instantiated. The class is
declared as follows: public abstract class Employee
Also, provide an abstract method called get Earnings() with a return type of double type. The
purpose of the getEarnings() method is to return the earnings that each type of employee
makes. Note: an abstract method is a method with no body. Below is it's declaration
public abstract double getEarnings ();
2. Create a Java class - Salaried Employee which is a special type of Employee with the following
additional attribute: weeklySalary. Provide appropriate get, set and equals(), toString()
methods. Implement a newer version of getEarnings() method that returns the earnings of
Salaried Employee: weeklySalary.
3. Create another Java class - HourlyEmployee which is another special type of Employee with the
additional attributes: wage and hours. Provide an appropriate set and get methods along with
equals(), toString method. Also, implement a newer version of getEarnings() method that
reflects earnings of HourlyEmployee. (Note: take into the account the rules for calculating the
earnings for the hourly employee as stated earlier in the problem description)
4. Create Java class-Commission Employee, another type of employee with attributes: grossSales
and commission Rate. Provide set, get and equals(), toString() methods. Provide a newer
version of getEarnings() method that returns the earnings as (commission Rate * grossSales).
5. Implement a specialized type of Commission Employee called BasePlusCommission Employee
class which has an additional attribute: base salary. Provide get, set and equals(), toString()
methods. Implement the getEarnings() method that returns the earnings as (commission Rate
grossSales) + baseSalary.
*
Note for all the above User-Defined Classes:
• Provide appropriate validation code so the right values get populated in the instance variables.
For example, the payrate should not be negative.
Write a Java application (Client) program with a static method called generate Employees() that returns
a random list of 10 different types of Employee objects. You would use an ArrayList to store the
employee objects that will be returned. Use a for loop to populate randomly different types of employee
objects with some random data. You could possibly think of a range of values like 1-4. If random value
is 1, create a HourlyEmployee object with some randomly generated data, if 2, a Salaried Employee
object with some random data and so on. I would leave it to your ingenuity to generate and populate
Transcribed Image Text:1. Write an Abstract Java class - Employee that encapsulates an employee's first name, last name, SSN. Implement the appropriate get and set methods along with toString() method and equals() method. Note: An abstract class is a class that cannot be instantiated. The class is declared as follows: public abstract class Employee Also, provide an abstract method called get Earnings() with a return type of double type. The purpose of the getEarnings() method is to return the earnings that each type of employee makes. Note: an abstract method is a method with no body. Below is it's declaration public abstract double getEarnings (); 2. Create a Java class - Salaried Employee which is a special type of Employee with the following additional attribute: weeklySalary. Provide appropriate get, set and equals(), toString() methods. Implement a newer version of getEarnings() method that returns the earnings of Salaried Employee: weeklySalary. 3. Create another Java class - HourlyEmployee which is another special type of Employee with the additional attributes: wage and hours. Provide an appropriate set and get methods along with equals(), toString method. Also, implement a newer version of getEarnings() method that reflects earnings of HourlyEmployee. (Note: take into the account the rules for calculating the earnings for the hourly employee as stated earlier in the problem description) 4. Create Java class-Commission Employee, another type of employee with attributes: grossSales and commission Rate. Provide set, get and equals(), toString() methods. Provide a newer version of getEarnings() method that returns the earnings as (commission Rate * grossSales). 5. Implement a specialized type of Commission Employee called BasePlusCommission Employee class which has an additional attribute: base salary. Provide get, set and equals(), toString() methods. Implement the getEarnings() method that returns the earnings as (commission Rate grossSales) + baseSalary. * Note for all the above User-Defined Classes: • Provide appropriate validation code so the right values get populated in the instance variables. For example, the payrate should not be negative. Write a Java application (Client) program with a static method called generate Employees() that returns a random list of 10 different types of Employee objects. You would use an ArrayList to store the employee objects that will be returned. Use a for loop to populate randomly different types of employee objects with some random data. You could possibly think of a range of values like 1-4. If random value is 1, create a HourlyEmployee object with some randomly generated data, if 2, a Salaried Employee object with some random data and so on. I would leave it to your ingenuity to generate and populate
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr