In this Practical you are first asked to define 3 classes to represent employees in a business. The first class called '
Posted: Thu May 05, 2022 12:45 pm
In this Practical you are first asked to define 3 classes to represent employees in a business. The first class called 'Employee' is an abstract class that will be the super-class for the classes 'Permanent' and 'Casual'. Permanent staff are paid a fixed salary each week. Casual staff are paid by the hours worked. The data and methods for each these is described below. You are then asked to write a main function called 'Payroll' that makes use of the classes above to calculate and record the payment of employees. 1. Employee. An abstract class with the following data members. a. String IDnumber b. String name c. double payRate // hourly rate d. PaySlippSlip // an array of Payslip objects e. int payIndex // the index of the next entry in the pSlip array f. double pay // Year to Date pay amount g. double YTDtax // Year to Date tax amount The class should have the following methods h. Constructor which accepts data for, and initialises IDnumber, name and payRate. i. A toString() method which returns a String which presents an employee object ID: 78332XD John Smith $16.50 p/h 22/3/2021 28 h $462.00 $69.32 23 h $379.50 $52.82 29/3/2021 3/4/2021 31 h $511.50 $79.22 YTD pay: $1352.00 $201.36 j. An abstract (virtual) method calcPay(int hours) that accepts the hours worked and returns the pay. k. A method to calculate the weekly tax according to the following rules. Estimate the Annual pay by multiplying the weekly pay by 52. If the Annual pay <= $6000 then tax = 0. If the Annual pay> $6000 then Annual tax = 0.2 * (Annual pay-6000). The weekly tax = Annual tax / 52. This method is the same for both Permanent and Casual employees. 2. PaySlip. This class holds data for each pay. An array of Payslip objects will be held in each Employee object as a history of their payments. Data members are a. string payDate // The default date.
b. int bours Worked c. double pay // the calculated pay (including tax) d. double tax // the calculated tax. Methods a. Constructor that accepts and updates the hours Worked pay and tax data. The payDate, is automatically set with the curent date. b. A toString() method to return a String representing a PaySlip object. This should display on a single line. You will have to format (your choice) the date to be shorter. Eg. Date, Hours, pay and tax as shown below 22/3/2021 28 h $462.00 $69.32 Permanent. This subclass of Employee represents permanent weekly paid employees. It has one additional data member. a. double holidays. // Each pay week 0.2 days are added. The class should include a constructor and override the abstract methods inherited from Employee b. Constructor which accepts data for, and initialises IDnumber, name and payRate. c. The toString() method must be over ridden to display the holidays due. d. The calcPax(40) method. Permanent staff default to 40 hours per week. Calculate the pay by multiplying the hourlyRate by 40. Calculate and update the XTDpay. Calculate the tax and update YTDtax. Create a new PaySlip object and store it in the pSlip array for that employee. The holidays data member is incremented by 0.2. 4. Casual. This subclass of Employee represents hourly paid employees. They do not receive holidays and do not have any additional data members to Employee. The class should include a constructor and override the abstract methods inherited from Employee a. Constructor which accepts data for, and initialises IDnumber, name and payRate. b. The toString() method. ID: 58332XD Paul Brown $14.50 p/h 22/3/2021 40 h $580.00 $92.92 29/3/2021 40 h $580.50 $92.92 03/4/2021 40 h $580.50 $92.92 YTD pay: $1740.00 $278.76 Holidays: 0.6 days c. The calcPay(hours) method. Calculate the pay data by
multiplying the bourlyRate by the hours worked. Calculate and update the YTDpay. Calculate the tax and update YTDtax. Create a new PaySlip object and store it in the pSlip array for that employee. Write a main program to display the menu options to test the class Then display the following menu Payroll Menu a. Add an employee b. Pay an employee c. Display Employee pay details d. exit.
b. int bours Worked c. double pay // the calculated pay (including tax) d. double tax // the calculated tax. Methods a. Constructor that accepts and updates the hours Worked pay and tax data. The payDate, is automatically set with the curent date. b. A toString() method to return a String representing a PaySlip object. This should display on a single line. You will have to format (your choice) the date to be shorter. Eg. Date, Hours, pay and tax as shown below 22/3/2021 28 h $462.00 $69.32 Permanent. This subclass of Employee represents permanent weekly paid employees. It has one additional data member. a. double holidays. // Each pay week 0.2 days are added. The class should include a constructor and override the abstract methods inherited from Employee b. Constructor which accepts data for, and initialises IDnumber, name and payRate. c. The toString() method must be over ridden to display the holidays due. d. The calcPax(40) method. Permanent staff default to 40 hours per week. Calculate the pay by multiplying the hourlyRate by 40. Calculate and update the XTDpay. Calculate the tax and update YTDtax. Create a new PaySlip object and store it in the pSlip array for that employee. The holidays data member is incremented by 0.2. 4. Casual. This subclass of Employee represents hourly paid employees. They do not receive holidays and do not have any additional data members to Employee. The class should include a constructor and override the abstract methods inherited from Employee a. Constructor which accepts data for, and initialises IDnumber, name and payRate. b. The toString() method. ID: 58332XD Paul Brown $14.50 p/h 22/3/2021 40 h $580.00 $92.92 29/3/2021 40 h $580.50 $92.92 03/4/2021 40 h $580.50 $92.92 YTD pay: $1740.00 $278.76 Holidays: 0.6 days c. The calcPay(hours) method. Calculate the pay data by
multiplying the bourlyRate by the hours worked. Calculate and update the YTDpay. Calculate the tax and update YTDtax. Create a new PaySlip object and store it in the pSlip array for that employee. Write a main program to display the menu options to test the class Then display the following menu Payroll Menu a. Add an employee b. Pay an employee c. Display Employee pay details d. exit.