Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

Ex 10.12 (Payroll System Modification) Modify the payroll system of Figs. 10.4–10.9 to include private instance variable birthDate in class Employee. Use class Date of Fig. 8.7 to represent an empl

Ex 10.12  (Payroll System Modification) Modify the payroll system of Figs. 10.4–10.9 to include private instance variable birthDate in class Employee. Use class Date of Fig. 8.7 to represent an employee’s birthday. Add get methods to class Date. Assume that payroll is processed once per month. Create an array of Employee variables to store references to the various employee objects. In a loop, calculate the payroll for each Employee (polymorphically), and add a $100.00 bonus to the person’s payroll amount if the current month is the one in which the Employee’s birthday occurs.

Ex: 10.14  (Payroll System Modification) Modify the payroll system of Figs. 10.4–10.9 to include an additional Employee subclass PieceWorker that represents an employee whose pay is based on the number of pieces of merchandise produced. Class PieceWorker should contain private instance variables wage (to store the employee’s wage per piece) and pieces (to store the number of pieces produced). Provide a concrete implementation of method earnings in class PieceWorker that calculates the employee’s earnings by multiplying the number of pieces produced by the wage per piece. Create an array of Employee variables to store references to objects of each concrete class in the new Employee hierarchy. For each Employee, display its String representation and earnings.

Show more
  • @
  • 22 orders completed
ANSWER

Tutor has posted answer for $10.00. See answer's preview

$10.00

** 1012 ******** System ************* Modify the payroll system ** **** ********* ** ******* ******* instance ******** birthDate ** class ******** *** class **** ** *** ** ** ********* an employee’s ******** *** *** ******* to class **** ****** **** ******* is processed **** *** month Create an array ** ******** variables to ***** ********** ** the ******* ******** objects ** a loop ********* the ******* for each Employee ***************** *** *** * ****** ***** ** the ********** ******* amount ** *** ******* month ** the *** in ***** *** Employee’s ******** occurs Solution :Employee ******** Fig **** Employeejava// ******** ******** **************** ******** ***** ******** * private ***** ****** ********** ******* final ****** ********* private ***** String ********************* ******* ***** Date birthDate;  public *************** ********* ****** ******** ****** ******************** Date ********** * ************* * ********** ************ = lastName; ************************ * socialSecurityNumber; ************* * ********** *** ** ****** ***** **** public ****** getFirstName() * return firstName; }  ** return **** name ****** ****** ************* * return ********* *** ** ****** social security ****** ****** ****** ************************* { ****** ********************* * ** return birth **** ****** Date ************** { ****** ********** *** ** ****** String representation ** ******** ****** ********* public String ********** { ****** **************** ********** security number: %s\nbirth ***** %s" getFirstName() ************* getSocialSecurityNumber()getBirthDate()toString()); }  ** ******** ****** **** be ********** by ******** subclasses ****** ******** ****** *********** ** ** implementation ******* ** end ******** ***** EmployeeDate Class:// *** *** Datejava ** Date ***** ******************* class **** *** private int ****** // **** ******* *** **** // **** ***** ** ***** private int ***** // any year  private ****** ***** ***** ************ = { ** ** 31 ** ** ** ** 31 ** ** ** ** **** ** ************ ******* proper value *** month *** day given *** **** ****** ******** ***** *** *** *** ***** * ** check ** ***** ** ***** ** ****** ***** ** ***** **** *** throw *** ******************************* (" * ***** * ** **** ** 1-12");  ** ***** ** *** ** range *** ***** ** (day ***** ** **** > ******************* ********** !(month ** 2 && *** ** ***** ***** new ***************************** (" * *** * ** ************ for *** ********* ***** and ********* // ***** *** leap **** ** ***** is * and *** ** ** ** ****** == 2 ********** *** == 29 ********** !(year % *** ** ** ***** % 4 ** ********** year % *** ** 0))) throw *** ***************************** ** * *** + ") out-of-range *** *** specified ***** *** year");  ********* * ****** thisday * **** ******** * ******* } ** ****** * String of *** **** ************** ****** ****** ********** { ****** *********************** ***** day ****** *** public *** getMonth() * ****** ****** *** ****** *** ******** { return **** }  ****** *** ********* * return year; }} ** *** class ********************* Class:import ********************* *** **** *********************** ******** ********* **** program public class ***************** *** ****** ****** void ************* ***** *** *** ************ = *************************************** * **** // ****** ******** objects SalariedEmployee **************** * *** ****************************** ************* 80000 *** ******* ** ******* ************** hourlyEmployee = new ********************** "Price""222-22-2222" **** ** *** Date(4 * ******* CommissionEmployee ****************** * *** ******************************* ************* ***** ** *** Date(5 8 1993)); ************************** ************************** = *** ******************************** ******* ************* **** ** 300 *** Date(2 ** ********* *************************** ********* ****************** ************************** ********* salariedEmployee ************************************ ************************ $%2f%n%n" ************** "earned"hourlyEmployeeearnings()); ************************ $%2f%n%n" ****************** ************************************** ************************ ********* ********************************** **************************************** // ****** ************ Employee ******* ********** employees * *** ************ // ********** array **** ********* employees[0] * ***************** ************ * hourlyEmployee; ************ = ******************* ************ * ***************************** ************************** processed ************************* // generically ******* **** ******* ** array ********* *** ********* *************** : ********** * ********************************** // ******* ********** ** determine ******* ******* ** a ************************** if (currentEmployee instanceof *************************** * ** ******** Employee ********* ** ** BasePlusCommissionEmployee reference BasePlusCommissionEmployee employee * **************************** **************** ************************* * *************************** **************** **** **** ****** **** **** ******** *** $%2f%n" employeegetBaseSalary()); } ** *** **** ** add * ****** ***** ** the person’s ******* ****** ** the ******* month ** ** *** *** in ***** *** ************ ******** ******** if (currentEmployeegetBirthDate()getMonth() ** ************* * Systemoutprintf("Birthday ***** : ******* ******* *********************** $%2f%n%n" ************************* + ******* * **** { *********************** ********* *************************** }  } // *** for  ** *** type **** ** each ****** in ********* ***** *** (int j = ** j **** **************** **** Systemoutprintf("Employee ** is * %s%n" * employees[j] *********************** * // *** main}SalariedEmployee Class// Fig **** ********************** **************** concrete ***** ******* abstract ***** ************** ***** **************** ******* Employee * ******* ****** *************** ** *********** public *********************** firstName String ******** ****** ******************** ****** ************ Date ********** * *************** ******** socialSecurityNumber ************* ** ************* **** *** ***** *** ******************************** ****** **** ** >= ******* **************** * ************* }  ** *** ****** public **** ********************** ************* * ** ************* < *** ***** *** IllegalArgumentException("Weekly ****** **** ** ***** ******* **************** = weeklySalary; *** ** return salary ****** double ***************** * ****** weeklySalary; *** // ********* ********* override abstract ****** ******** ** Employee ********* ****** ****** earnings() * ****** getWeeklySalary(); *** ** return ****** ************** of **************** ****** ********* ****** ****** ********** { return Stringformat("salaried ********* ******* ***** *************** ******* ******* ******************* } } ** *** ***** ******************************** ************** ***** HourlyEmployee ******* Employee *** private ****** wage; ** wage *** hour ******* ****** ****** ** ***** ****** *** ****** ** constructor ****** ********************* ********* String lastName ****** ******************** ****** **** ****** hours **** birthDate) { super(firstName ******** ******************** ************* if ***** < *** ** validate **** throw *** IllegalArgumentException("Hourly wage **** ** ***** ******* ** ******* **** *** || ****** > 1680)) ** ******** ***** ***** *** ************************* ****** ****** **** ** ***** ** *** <= ********* ******** * ***** ********* = hours; *** ** *** **** public **** setWage(double ***** * ** ***** **** *** // ******** wage ***** *** IllegalArgumentException("Hourly **** **** ** >= ******* ******** * wage; *** ** return **** public double ********* * ****** ***** *** ** *** hours ****** public **** *************** ****** * ** ******* < 00) || ****** **** 1680)) ** validate ***** ***** *** IllegalArgumentException( ****** worked **** ** >= 00 *** <= ********* thishours = ****** *** ** ****** hours worked ****** ****** getHours() * ****** ****** *** ** *** *** * ************** ***** ******* ******** (Part 2 ** ** ** ********* ********* ******** ******** ****** ******** ** ******** @Override ****** double earnings() { ** *********** ***** *** ** ** ******** ****** ********* * getHours(); **** ****** ** * ********* * *********** * *** * ********* * *** }  ** ****** String ************** ** ************** ****** ********* ****** String ********** * ****** ******************** ********* ******* ***** *** **** *************** "hourly wage" ********* "hours ******* ************ ****************************** ******** *** **** BasePlusCommissionEmployeejava// ************************** class ******* ************************ ***** ************************** ******* ****************** { private double *********** ** **** ****** *** ****** ** *********** ****** BasePlusCommissionEmployee(String ********* ****** lastName ****** socialSecurityNumber double ********** ****** commissionRate ****** ********** Date birthDate) * *************** ******** socialSecurityNumber ********** commissionRatebirthDate);  ** (baseSalary < 00) ** ******** baseSalary ***** *** ****************************** ****** must be ***** 00");  ************** * baseSalary; *** ** set **** ****** ****** **** ******************** *********** * ** *********** **** 00) ** ******** ********** ***** new ****************************** ****** **** ** ***** ******* thisbaseSalary = *********** }  // ****** **** salary ****** ****** *************** * ****** baseSalary; *** ** calculate ********* ******** ****** earnings in ****************** ********* ****** double ********** * ****** *************** + **************** *** ** return ****** ************** ** ************************** ****** ********* public ****** ********** { return Stringformat("%s *** %s: ***** *************** *************** ***** salary" ***************** ************************ Class *** *** **** ************************ ****************** ***** extends ************** class CommissionEmployee ******* ******** * ******* double *********** // ***** ****** sales ******* double commissionRate; // ********** ************ // *********** public CommissionEmployee(String ********* ****** lastName String socialSecurityNumber double grossSales double commissionRateDate birthDate) * *************** ******** ********************************* ** *************** ***** ** || ************** ***** *** ** ******** ***** *** ************************* *********** rate **** ** > ** *** **** ******* ** *********** **** 00) ** ******** ***** new IllegalArgumentException("Gross ***** must ** ***** ******* thisgrossSales = *********** ****************** = *************** *** ** *** gross ***** ****** public void setGrossSales(double *********** * ** *********** **** *** ** ******** ***** *** ******************************* ***** **** ** ***** ******* thisgrossSales * *********** *** ** return ***** ***** ****** public ****** *************** { return grossSales; *** ** *** ********** **** ****** void ************************ commissionRate) * if *************** ***** ** ** ************** >= *** // ******** throw new ************************* *********** **** **** ** **** ** *** < ******* thiscommissionRate * commissionRate; }  // ****** ********** **** public ****** ******************* * ****** *************** *** ** ********* ********* override ******** ****** ******** ** ******** ********* public ****** earnings() * ****** ******************* * getGrossSales(); }  ** return ****** ************** ** ****************** ****** ********* public ****** toString() { return ***************** %s%n%s: $%2f; %s: **** "commission ********* *************** ****** ****** *************** *********** ***** getCommissionRate()); ************************** ********* individually: salaried employee: **** *********** ******** ******* **************** date: 7/23/2016weekly ******* $80000earned: ************** employee: Karen *********** ******** number: **************** ***** ************** ***** ****** ***** ******* *********** ****************** ********* *** *********** security ******* **************** ***** 5/8/1993gross ****** ********* ********** ***** 006earned: ********************* commission employee: *** Lewissocial ******** number: 444-44-4444birth ***** ************** ****** ******** ********** ***** **** **** salary: ************* ***************** ********* ************************** ********* **** *********** security ******* **************** ***** 7/23/2016weekly salary: $80000Birthday bonus * ************ ************** ********* Karen *********** security ******* **************** ***** ************** ***** ****** hours ******* ********** $67000 commission ********* *** *********** ******** ******* 333-33-3333birth ***** 5/8/1993gross ****** ********* commission ***** ********* ********************* commission ********* *** Lewissocial security ******* **************** ***** ************** ****** ******** ********** rate: 004; **** ******* ********* **** ****** **** *** ******** *** ************ **************** ** a ************************ 1 ** * ********************** * ** a CommissionEmployeeEmployee * is a ***************************** **** ******** ****** ************* ****** *** ******* ****** ** **** 104–109 to ******* ** additional ******** subclass *********** **** represents ** employee ***** *** ** ***** ** *** ****** of ****** ** merchandise ******** ***** *********** ****** ******* private ******** ********* **** *** store the ************ **** *** ****** and ****** (to ***** *** ****** ** ****** ********* ******* * concrete implementation ** ****** ******** ** class *********** **** ********** *** employee’s earnings ** *********** *** ****** of pieces produced ** *** **** *** piece Create ** ***** ** Employee ********* to store ********** to objects ** each concrete ***** ** *** *** ******** ********* *** **** ******** ******* *** ****** representation *** ************************************** Class://PieceworkerEmployee ***** extends Employeepublic ***** ******************* extends Employee {  private ****** ***** ** **** per one ***** ******* int pieces; ** number ** ****** ********** ****** PieceWorkerEmployee(String ********* ****** ******** ****** ******************** double ***** int ***** **** ********** * super(firstName ******** socialSecurityNumber *********** setWages(wages); ***************** *** // sets ***** of ******** ****** void *************** wages) * wage * (wages **** *** ? ***** * *** *** // gets wages of ******** public ****** getWages() * return ***** *** ** **** ****** ** pieces produced ** ******** ****** **** setPieces(int ****** * ****** = ****** **** ** * * ****** *** ** ******* ****** ** ****** ****** *** *********** * return ******* *** ** ********* earnings; override ******** ****** ******** ** ******** ****** ****** earnings() { return getWages() * ************ *** ** ****** ****** ************** of ******************* ******** ****** ****** ********** {  ****** ***************** %s%n%s: ***** *** %d" "PieceWorker ********* *************** "wage *** ****** ********** ******* produced" getPieces()); ******************* Class:import ********************* *** **** *********************** ******** ********* test program public ***** PayrollSystemTest *** public ****** **** ************* ***** *** *** currentMonth = CalendargetInstance()get(CalendarMONTH) * **** ** Create subclass objects **************** **************** * *** SalariedEmployee("John""Smith" ************* ***** *** Date(07 ** ******* HourlyEmployee ************** * *** ********************** ******************** **** ** *** ****** * ******* ****************** ****************** * *** ******************************* "333-33-3333" 10000 ** *** ****** * ******* ************************** ************************** * *** ******************************** ******* ************* **** 04 *** *** ****** ** 2000)); ******************* pieceworkerEmployee * *** PieceWorkerEmployee("George""Levo" ********************** Date(4 * 1981));  Systemoutprintln("Employees ********* ****************** ************************** ********* salariedEmployee ************************************ Systemoutprintf("%s%n%s: ********* hourlyEmployee "earned"hourlyEmployeeearnings()); Systemoutprintf("%s%n%s: $%2f%n%n" ****************** ************************************** Systemoutprintf("%s%n%s: ********* ********************************** basePlusCommissionEmployeeearnings()); ************************ $%2f%n%n" ************************************************************ ** create four-element ******** ******* Employee[] ********* * *** Employee[5]; ** ********** array **** ********* employees[0] * ***************** ************ * *************** ************ * ******************* employees[3] * *************************** ************ * ********************** Systemoutprintf("Employees ********* ************************* ** *********** ******* each ******* ** ***** ********* for (Employee *************** * employees) * ********************************** ** ******* ********** ** determine ******* ******* ** * ************************** if **************** ********** *************************** * ** ******** Employee ********* ** ** ************************** ********* ************************** ******** = **************************** **************** ************************* * *************************** Systemoutprintf( **** **** salary with 10%% ******** is: ******* employeegetBaseSalary()); * ** end **** ** *** a ****** ***** ** *** ********** ******* ****** if *** current month is // *** one in which *** Employee’s birthday ******** if **************************************** ** currentMonth) { Systemoutprintf("Birthday ***** * $%2f%n" 10000); Systemoutprintf("earned $%2f%n%n" currentEmployeeearnings() * ******* * else { Systemoutprintf("earned ********* currentEmployeeearnings()); *** * ** *** ***** ** *** type **** of **** ****** in employees array *** **** * * ** * **** **************** **** ************************* ** ** * %s%n" j ************ *********************** * ** *** ********************* ********* *********************** ********* **** *********** ******** ******* **************** date: 7/23/2016weekly ******* ************* ************** employee: Karen *********** ******** ******* **************** ***** 4/2/1981hourly wage: ****** hours ******* 4000earned: ****************** ********* *** Jonessocial ******** number: 333-33-3333birth ***** ************* sales: ********* ********** ***** ********** ********************* ********** employee: *** *********** ******** ******* **************** ***** ************** ****** ******** commission ***** **** **** salary: ************* ******************* ********* ****** Levosocial ******** ******* **************** ***** ************ per ****** $9000; ****** ********* ********* ***************** processed ************************** ********* **** *********** ******** ******* **************** ***** *************** ******* $80000Birthday ***** * ************ ************** employee: ***** *********** ******** ******* **************** ***** ************** ***** ****** ***** ******* ********** ****************** ********* *** Jonessocial ******** number: **************** date: ************* sales: $1000000; commission rate: ********* $60000 base-salaried ********** ********* Bob *********** ******** ******* 444-44-4444birth ***** 2/29/2000gross ****** ******** commission ***** 004; **** salary: ********* **** ****** **** 10% ******** is: ************ $53000 PieceWorker ********* ****** ********** security ******* **************** ***** 4/2/1981wage *** ****** $9000; ****** ********* ******** **************** is a ************************ 1 ** * ********************** * ** * ************************** * ** * ********************************** 4 ** a *********************

or Buy custom answer
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question