Question: Write a program that consists of an abstract class called Worker. The class should have the following protected variable types of information: Worker name Worker

Write a program that consists of an abstract class called Worker. The class should have the following protected variable types of information:

Worker name

Worker number

Hire date Create one or more constructors and the appropriate accessor and mutator functions for the class. Create an abstract function called calculatePay that will calculate and return the total payment of the worker.

Next, create a class name ProductionWorker that is derived from the Worker class. The ProductionWorker class should have member variables to hold the following information:

Shift (an integer, 1=day, 2=night)

Hourly pay rate (a double)

Hours worked (a double)

Create one or more constructors and the appropriate accessor and mutator functions for the class. Create a function called calculatePay that will calculate and return the total payment of the worker. The payment should be the hourly rate multiply by the hours worked. The payment should be double pay for hours worked greater than 40.

A shift supervisor is a salaried worker. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Create a class called ShiftSupervisor that is derived from the Worker. The ShiftSupervisor class should have a member variable that holds the annual salary and a member variable that holds the annual production bonus that a shift supervisor has earned. Create one or more constructors and the appropriate accessor and mutator functions for the class. Create a function called calculatePay that will calculate and return the total payment of the supervisor payment (salaried + bonus earned).

Write a driver program that will implement the three classes mentioned above. Ask the user how many workers to input (at least four). Makeup all the input values. Your program should use the 2 Java ArrayList class to create an object of Workers. Using the loop concept reiterates through the ArrayList of objects and prints each workers information. Print the result in a readable format so that readers will understand what they are reading about.

Name

Worker number

Worker type

(ProductionWorker or ShiftSupervisor)

The workers payment Your program should offer the user to observe the result in two ways: a) Displays the result on the console. b) Save the result into a file. Request the user to input the file name.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!