Project 5: Payroll Calculation
Due date: April 26/ April 27th
Introduction
This program is supposed to
calculate the yearly salaries for two different types of employees: part-time
and full-time. The full-time employees' monthly salary is fixed, based on their
employee level. The part-time employee' salary is based on the number of hours
they work. You are supposed to use inheritance in this project to represent the
relationships between an Employee class and the two other types of classes: FullTimeEmployee
and PartTimeEmployee.
Program Details
You should implement five
different classes: testDriver, Database, Employee, FullTimeEmployee and PartTimeEmployee.
The classes and their relationships are indicated in the class diagram shown
below.
All the
five classes are described below.
testDriver
This class is used to test the other classes.
This class should read the employee details from an input file called 'employeedata.txt' and create a database of employees. The input
file contains an arbitrary number of lines. Each line follows the format
indicated below
ID First Last Code Dept Level PayRate Ded Months Hrs
Each field is explained below
ID:
The employee ID (a nine digit number)
First:
The first name of the employee
Last:
The last name of the employee
Code:
A single letter code indicating whether the employee is part-time ('P') or
full-time ('F')
Dept:
The department code (a four character string)
Level
: This is applicable only for full-time employees and indicates their salary
levels. The acceptable levels are A, B, C, D and E. The monthly salaries are based
on this code is indicated in the table below. The value of this field will be N
for part-time employees.
Table
1:
|
Employee Level |
Salary |
|
A |
3500 |
|
B |
4500 |
|
C |
5500 |
|
D |
6200 |
|
E |
6500 |
PayRate: This is applicable only for the
part-time employees and indicates the pay rate per hour for each part-time
employee. The value of this field will be 0 for full-time employees.
Ded: This indicates the total
deductions for each employee.
Months: This is applicable only for the
full-time employees and indicates the number of months they have worked for.
The value of this field will be 0 for part-time employees.
Hrs: This is applicable for part-time
employees and indicates the number of hours they worked. The value of this
field will be 0 for full-time employees.
The testDriver class should read these lines
from the input file, create appropriateFullTimeEmployee
or PartTimeEmployee
objects and add them to a database object. After adding them, it
should invoke the print method of the database to print to the
output file,
'employeeInformation.txt' the
salary and details about each employee.
Database
This class should build a database
of Employee entries using an ArrayList. There should
be just one object of type ArrayList which would store both Full Time and
Part Time employee information. This class
should have a print method that prints the details of each employee including
their calculated salaries. This method should call print methods of the
appropriate class based on the employee details to print their details.
The general signature of this
method will be:
public void print(PrintStream ps)
Note:
You are creating only one
PrintStream
object in the
testDriver
class and then passing this object to other classes.
Employee
This class should contain basic
information about each employee. This should include the employee id, first name,
last name, and department code. These should be declared as private.
FullTimeEmployee
This class extends the Employee class and should add information that is pertinent to a full-time employee only. This class should have a calculateSalary() method that calculates the salary based on Table 1. This class should also have a print method that prints out the details about each employee including their salary.
Salary for FullTimeEmployee = (Month * Employee Level) - Ded
PartTimeEmployee
This class extends the Employee
class and should add information that is pertinent to a part-time employee
only. This class should have a calculateSalary() method
that calculates the salary based on the pay rate and number of hours worked.
This class should also have a print method that prints out the details about
each employee including their salary.
Salary for PartTimeEmployee = (Hrs * PayRate) - Ded
Hints
1. Refer to the Java API at http://java.sun.com/j2se/1.4.2/docs/api/
whenever you need to
get more information about particular classes.
2. Refer to Chapters 8 and 9 of
your book to understand better the concepts of inheritance.
Programming
Standards
You'll be
expected to observe good programming and documentation standards. All thediscussions
in class about formatting,
structure, and commenting your code will be enforced. The given code satisfies
the documentation standards below. You will be expected to follow these
standards and others in all of your later programs. Some, but not necessarily
all, specifics include:
Testing
You should test your program within the BlueJ environment to make sure that you implemented all the above requirements correctly. You should be certain that your program produces the output given above when you use the given input file and the sample test files provided on the course web site. However, verifying that your program produces correct results on a few test cases does not constitute a satisfactory testing regimen. You should make up and try additional input files as well; of course, you'll have to determine what the correct output would be. Your program for this project is a stand-alone program. No other program will invoke its methods. You should invoke the main method of the class in the BlueJ environment to run the program.
Sample Input files: employeedata.txt employeedata1.txt employeedata2.txt
Sample Output files: employeeInformation.txt employeeInformation1.txt employeeInformation2.txt
Program
Compilation
Your program must compile and run
under JDK 1.4.
Pledge
Every program submission for this
class must include an Honor Code pledge. Specifically, you
must always include the following pledge
statement in the header comment for your program:
/***********************************************************************
*
* On my honor:
*
* - I have not
discussed the Java language code in my program with
* anyone
other than my instructor or the teaching assistants
* assigned to this
course.
*
* - I have not used
Java language code obtained from another student,
* or
any other unauthorized source, either modified or unmodified.
*
* - If any Java
language code or documentation used in my program
* was obtained from
another source, such as a text book or course
* notes, that has been
clearly noted with a proper citation in
* the
comments of my program.
*
* - I have not
designed this program in such a way as to defeat or
* interfere with the
normal operation of the Curator System.
*
* Your Name
* Your PID
***********************************************************************/
Failure to include
this pledge in a submission is a violation of the Honor Code.