Question: Write a Java program to compute the weekly pay for each employee and the total payroll. You do not know the number of employees in

Write a Java program to compute the weekly pay for each employee and the total payroll. You do not know the number of employees in advance. The first item in the report will be the first name, the second item in the line will be the last name, the third item will always be the employee type (Manager, Design, Manufacturing, Sales). For a Manager, the salary will be the fourth item. If the type is Design, hourly salary is the fourth item and hours worked is the fifth item. If the type is Sales, the fourth item will be the gross weekly sales. If the type is Manufacturing, the fourth item will be the price per piece and the fifth item will be the number of pieces. The last item on the line will be the worker's ID number.

An employee can also be added through the GUI.

A Summary Pay Report is displayed on the screen in a JOptionPane window. Each employee number and weekly wage is printed before the summary items. The summary should consist of the total payroll and the number of employees in each category. Use the FileChooser dialog box to select the input file name at run time. Print all dollar amounts with currency formatting. You can assume all information in the input file is correct.

Allow the user the read in an employee text file (provided), add an employee in the GUI, or remove an employee.

Specifications

Data Element - Employee

Create an abstract class called Employee with one abstract method called calculateWeeklyPay which returns a double. This class will have an instance variables (one of them is an object of type Position, from Assignment 5), a toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor.

Data Element subclasses of Employee

Create the following classes for the 4 types of employees: Manager, Design, Sales, and Manufacturing. They will contain instance variables appropriate for the type of employee. They will extend from Employee and define the calculateWeeklyPay method. There should be getters and setters, and any other methods that are needed for your design. The toString method and constructors for these classes will use the super reference to take advantage of the Employee constructor and toString methods. Use finals to represent constants.

Enumerated Type Position

Create an enumerated type called Position. The valid values will be MANAGER, SALES, DESIGN, MANUFACTURING. Add any additional methods or instance variables as required by your design.

Data Structure

You will be using an Arraylist within your Data Manager to hold the employee objects.

Data Manager - Company

Create a Company class that implements the CompanyInterface. It will contain an arraylist which holds references to Employee objects (Manager, Design, Sales, Manufacturing all inherit from Employee). It will have methods to addEmployee, removeEmployee, printEmployees, calculateTotalWeeklyPay, retrieve number of Design employees, Sales employees, etc., and any other methods needed for your design. Your toString method will print out the employee number and weekly pay for all employees. There is a generateWeeklyPayReport method that returns a string with the entire report.

GUI Driver

Create a GUI Driver class/classes. The preferred submission will be using JavaFX, although Swing submissions are also acceptable. The driver launch the GUI, which can read from a file, add or remove an employee, print a summary of employees, and print a pay report by employee. Use the FileChooser dialog box to select the input file name at run time. The number of fields in the file for one employee will change depending on the type of employee that is selected. The fields in the file are separated by colons (:). You can assume all information in the file is correct. The GUI will use an instance of the Company class.

The user will have the ability to add additional employees through the keyboard. The labels and textfields will change depending on the type of employee that is selected to be added.

The user will have the ability to remove an employee. If there are not employees yet added, use a JOptionPane to tell the user to add employees first. If the user does not type the first and last name of the employee to be removed, use a JOptionPane to display the current employees and tell the user to type in a name.

Display a report of all employees, and a weekly pay report for all the employees

Supplied Code

/**

* Contains an ArrayList of objects that inherit from the Abstract class Employee

* Keeps track of the number of Mangers, Designers, Sales

* and Manufacturing employees

* Manages company employees

* Create a static variable to keep track of the number

* of company instances created

*

*/

public interface CompanyInterface {

/**

* Add an employee to the ArrayList.

* @param type Type of employee: Manager, Design, Sales, Manufacturing

* @param fname First Name

* @param lname Last Name

* @param firstParam Manager-salary, Design-hourly rate, Sales-weekly sales, Manufacturing-rate per piece

* @param secondParam Manager-not needed (0), Design-number of hours, Sales-not needed (0), Manufacturing-number of pieces

* @param empNum employee number

* @return null if successful add. Returns a string that describes the reason

* for not adding the employee. It will be one of the following:

*

1. There is already a sales person Employee not added

*

2. There are already two design persons Employee not added

*

3. There are already four manufacturing persons Employee not added

*

4. There is already a manager Employee not added

*

5. There are already 8 employees Employee not added

*/

public String addEmployee(String fname, String lname, String type, double firstParam, int secondParam, int empNum);

/**

* Remove a specified employee from the ArrayList.

* @param firstName First name of the employee to remove from the payroll

* @param lastName Last name of the employee to remove from the payroll

* @return true if the employee was successfully removed, false otherwise

*/

public boolean removeEmployee(String firstName, String lastName);

/**

* Returns the number of Managers in the ArrayList

* @return number of Managers

*/

public int getNumManager();

/**

* Returns the number of Hourly Workers in the ArrayList

* @return number of Hourly Workers

*/

public int getNumDesign();

/**

* Returns the number of Commission Worker in the ArrayList

* @return number of Commission Worker

*/

public int getNumSales();

/**

* Returns the number of Piece Worker in the ArrayList

* @return number of Piece Worker

*/

public int getNumManufacturing();

/**

* Generates a weekly report of employee weekly pay

* @return String that contains the Weekly Report

*/

public String generateWeeklyReport();

/**

* Calculate the total weekly pay for all employees in the ArrayList

* @return the total weekly pay for all employees

*/

public double calculateTotalWeeklyPay();

/**

* Creates a string with the name of the company followed by the first and last name

* and position of each of the employees

* @return string

* Example:

*

PigeonHawks

*

John Smith Position: Manufacturing

*

Bob Jones Position: Sales

*/

public String printCompany();

/**

* Creates a string representation of the object

* @return String that represents all the objects in the ArrayList

*/

public String toString();

}

the data file

John:Smith:Manufacturing:6.75:120:444 Betty:White:Manager:1200.00:111 Stan:Slimy:Sales:10000.00:332 Betty:Boop:Design:12.50:50:244 

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!