Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA COMPLETE ALL METHOD The Problem You are going to write classes to handle a ( greatly simplified ) company payroll. You will also

IN JAVA COMPLETE ALL METHOD
The Problem
You are going to write classes to handle a (greatly simplified) company payroll. You will also
complete test programs that exercise each of those classes. You will be given a starting point for
each of the test programs which you will fill in following the instructions in the comments.
The Classes
You will write two data classes: an HourlyEmployee class that manages information a single
employee and a Payroll class that contains an array of HourlyEmployee objects and manages
payroll for them. You will also complete the provided EmployeeTester and PayrollTester
classes to thoroughly test your classes. Make sure that your classes follow the specifications
below precisely and that your output matches the sample output provided. You may create
additional private methods and constants as you deem appropriate. Additional instance variables
are not permitted.
The HourlyEmployee Class
This class must have exactly the following instance variables (attributes/fields):
name: the full name of the employee
employeeID: the employees company ID number (note that this may include letters)
hourlyRate: the amount the employee is paid per hour
accruedLeaveHours: the number of hours of leave the employee has available to use.
These will be accrued at the rate of 1 per 8 hours worked (including overtime). Note that
partial hours are possible.
annualHoursWorked: the number of hours the employee has worked year-to-date. Only
hours actually worked are included, not leave.
annualEarnings: the amount the employee has earned year-to-date.
This class must have at least the following methods:
A default constructor
A constructor that accepts only the name, id, and hourly rate, setting other fields to 0.
This would be appropriately used for new employees.
A constructor that accepts parameter for all instance variables.
A getter for the id.
A toString method that returns the data with labels and formatting that matches the
sample output.
A read method that accepts a Scanner and reads the data for the employee from the
Scanner. Information about an employee will be stored on two lines. The first will
contain the employees name. The second will have the remaining data in the order listed
above. See the sample files provided. You should assume that the id will never contain
spaces.
A write method that accepts a PrintWriter and writes the data to that PrintWriter in the
same format as it is read.
A handlePay method that accepts two parameters: the number of hours worked for the
week, and the amount of leave used that week. The method will compute pay; update
leave accrued, annual hours worked, and annual earnings; and output the following
information:
earned and has hours of leave accrued.
Rules for the weeks work are:
o Cant use more leave that was previously accrued. Any earned this week doesnt
count. Must limit the leave used to no more than what is available.
o Cant use leave to get overtime. If the hours worked and leave used sum to more
than 40, the amount of leave must be limited so that no more than 40 hours of pay
is received or leave is 0.
o Work above 40 hours is paid double. Someone who makes $20/hour and works 42
hours will receive $880.
o Overtime work does count toward leave accumulation.
o Used leave does not count toward leave accumulation.
Other notes:
Any time you are printing to the screen, hours should be formatted with at least 1 digit
before and exactly 1 digit after the decimal point. So 0 will be 0.0.2.28 will be 2.3.
Any time you are printing to the screen, you should be formatting currency properly.
Data written to the file should not be formatted.
Make sure you look at the sample input and output files as well as the sample console
output in sample EmployeeTester output.txt to help you understand expectations and
formatting.
The EmployeeTester Class
Ive provided a starting point for this class with a lot of comments. Follow the instructions in the
comments, referring to the sample output for clarification (and reaching out to me for further
clarification as needed).
You should be completing this class as you work on the HourlyEmployee class, using the tester
class to check your work on the employee class as you go. Do not write the whole
HourlyEmployee class and then start work on the tester class. That may sound faster, but it will
almost certainly be much slower.
The Progress submission will consist of a zip file containing your HourlyEmployee.java and
EmployeeTester.java files. Note that if your progress submission is incomplete, you will
receive credit for only the portions of the HourlyEmployee that are tested by your
EmployeeTester.
The Payroll Class
The Payroll class must have the following instance variables:
An array of HourlyEmployee objects that the Payroll object manages
The number of employees currently in the Payrol

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions