Here is the solution, if you have any type of doubts then you can write in the comment section.
Please give feedback.
Solution:
case "H":
{
firstName=lineElements[1];
lastName=lineElements[2];
rate=lineElements[3];
hours=lineElements[4];
deptName=lineElements[5];
checks=lineElements[6];
//conversion of String to double
double Rate=Double.parseDouble(rate);
double Hours=Double.parseDouble(hours);
/*try catch block for handling Exception thrown by constructor of
HourlyEmployee class*/
try
{
//creating Object of HourlyEmployee() class
Employee employee=new HourlyEmployee(firstName,lastName,Rate,Hours);
/*we can also create abovet Object as
HourlyEmployee employee=new HourlyEmployee(firstName,lastName,
Rate,Hours); */
//call parsePaychecks() method
payrollSystem_Phase3.parsePaychecks(employee,checks);
//call findDepartment() method
Department d=company.findDepartment(deptName);
//if Department is present then addEmployee to it
if(d!=null)
{
d.addEmployee(employee);
}
}
//if Exception raised
catch(Exception e)
{
e.printStackTrace();
}
}
Thank You!
In the processLineOfData method, write the code to handle case "H" of the switch statement such...
In the processLineOfData, write the code to handle case "H" of the switch statement such that: An HourlyEmployee object is created using the firstName, lastName, rate, and hours local variables. Notice that rate and hours need to be converted from String to double. You may use parseDouble method of the Double class as follows: Double.parseDouble(rate) Call the parsePaychecks method in this class passing the HourlyEmployee object created in the previous step and the checks variable. Call the findDepartment method...
Modification to be completed by group member 4: In the processLineOfData method, write the code to handle case "M" of the switch statement such that: A Manager object is created using the firstName, lastName, salary, and bonus local variables. Notice that salary and bonus need to be converted from String to double. You may use parseDouble method of the Double class as follows: Double.parseDouble(salary) Call the parsePaychecks method in this class passing the Manager object created in the previous step...
Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...
Rewrite following code down below using Factory Pattern. -------------------------Staff.java--------------------------- import java.util.*; public class Staff extends Employee { private int HourlyRate; /**Constructor Staff which initiates the values*/ public Staff() { super(); HourlyRate=0; } /**Overloaded constructor method * @param ln last name * @param fn first name * @param ID Employee ID * @param sex Sex * @param hireDate Hired Date * @param hourlyRate Hourly rate for the work...
Given attached you will find a file from Programming Challenge 5 of chapter 6 with required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: An empty string is given for the employee’s name. An invalid value is given to the employee’s ID number. If you implemented this field as a string, then an empty string could be invalid. If you implemented this field as a numeric variable, then a...
By editing the code below to include composition, enums, toString; must do the following: Prompt the user to enter their birth date and hire date (see Fig. 8.7, 8.8 and 8.9 examples) in addition to the previous user input Create a new class that validates the dates that are input (can copy date class from the book) Incorporate composition into your class with these dates Use enums to identify the employee status as fulltime (40 or more hours worked for...
Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...
Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so they throw exceptions when the following errors occur. - The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. - The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. - The ProductionWorker class should thrown anexception named InvalidPayRate when it receives a negative number...
Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...