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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education