Select Page
  

I attached the two files for details
programmingassignment2.docx

project2employeedata.txt

Don't use plagiarized sources. Get Your Custom Essay on
CS 111 project programming
Just from $10/Page
Order Essay

Unformatted Attachment Preview

Project
100 Points
Key Concepts: Reading data from a file, Inheritance, Polymorphism, interfaces and
Abstract Classes, sorting and searchig (all of these topics will be covered with
sufficient time before the project due date)
In this project you will be writing a payroll system for the Crunchy Crème Cupcake
Factory. Employees are paid twice a month, on the 15th and last day of the month. The
factory employees 3 categories of employees:
• Salaried employees who are paid based on a yearly salary, which is divided
between 24 pay periods.
• Commission based employees, who have a yearly salary (24 pay periods), but also
earn commission based on their sales during each pay period.
• Hourly employees who are paid by the hour. These employees may be eligible
for overtime pay, but in general work at least 40 hours per week.
Your payroll system, will read a file of employee data, and store the information for each
employee into an array. Finally, you will calculate the pay for each employee by visiting
each employee element in your array and calling the appropriate method to calculate pay,
and print a report that has one line for each employee in the array
For this project you will create classes representing the different category of employees,
along with an abstract employee class that contains information common to all employees
(some of which is provided for you). You will need to write the following classes:
Employee: you will define an ABSTRACT class called employee that will serve as the
base class of the other classes in your application. This class will have the following
private data members: This class MUST be named Employee
ID: integer
First name: String
Last Name: String
Title: String
Total Pay: Float
Methods:
• You will need a single constructor that receives a value for each of the data
members except total pay, which should be initialized appropriately.
• You will need getter/setter methods for each data member
• This class must implement the comparable interface, which means you must
write a compareTo method which will first compare the employee type (using the
“instanceOf” method, and then if the type of two objects is the same, then
compare the employee id. Employees are sorted by type, and then ID
• You will also declare two abstract methods:
o One is a void method called calculatePay which given the data in the
object calculates the employee’s pay, and stores it in the total pay data
member.
o The second is a void method called print(). This method will print the
contents of an employee object, in the format needed by your payroll
report for that type of employee.
Commission Employees:
This class MUST be named Commission
This class represents employees who earn commission on sales each pay period and is a
subclass of class Employee. This class has the following data members
Salary: Float // base salary
Commission Rate: Float // percentage of sales, earned as commission
Commission Sales: Float // sales this pay period
Threshold: Float // This is the amount of sales an employee must earn before
// they are eligible to earn commission, for example an employee
// might have to sell $15000 in products before earning
// commission. if they sell less than $15000 they earn no
//commission if they sell $20000 then they earn commission on
// $5000
Methods:
• You will need a single constructor, which receives an employees first and last
name, title, type, ID, salary threshold amount, and commission rate
• You will need getters/setters for all of the private data members of this class.
• You will need a calculatePay() method, that calculates this employees pay as:
o if the employee’s sales are less than or equal to the threshold, then they
earn No commission and are just give their base salary
o IF the sales are > than the threshold then the employee receives their
regular salary PLUS (the commission sales – threshold) * commission
rate

You will need to write a void print() method that will display the contents of this
type of object in a format compatible with your payroll report.
Salaried: this class MUST be named
Salaried
This represents a category of employees who are paid based on an annual salary, this
class implements the data member:
Salary: float // annual salary
Methods:



You will need a single constructor, which receives an employees first and last
name, title, type, ID, and salary
You will need getters/setters for of the private data member of this class.
You will need a calculatePay() method, that calculates this employees pay as:
totalPay = (Salary/24);

You will need to write a void print() method that will display the contents of this
type of object in a format compatible with your payroll report.
Hourly: This class MUST be named Hourly
This represents a category of employees who are paid by the hour. These employees may
or may not be eligible for overtime pay if they work more than 80 hours during the pay
period. This class implements the data members:
Hours Worked: Float // hours worked this pay period
Hourly Rate: Float
Overtime Eligible: Boolean
Methods:





You will need a single constructor, which receives an employees first and last
name, title, type, ID, hourly rate, and overtime eligible.
You will need getters for all of the private data members of this class.
You will need a SINGLE setter for the Hours Worked data member.
You will need a calculatePay() method, that calculates this employees pay as:
o If the employee is NOT overtime eligible the pay is calculated as the hours
worked times the hourly rate.
o If the employee IS overtime eligible for the first 80 hours they are paid by
their hourly rate, for every hour over 80, they are paid 1 ½ times their
hourly rate
You will need to write a void print() method that will display the contents of this
type of object in a format compatible with your payroll report.
Your main program:
Again your main program/ and supporting static methods are the workhorses of this
project, USE FUNCTIONAL DECOMPOSITION… It is not acceptable for main to
do all of the work.
1. We are going to use Polymorphism to allow us to store objects of our various
employee types into an array of the abstract type Employee. We will begin by
declaring an array of type employee. This will contain the information read from
the main data file for each employee. WE employee 30 employees.
TASKS
2. You will prompt the user for the name of and open the employee data file, and
read each line, since there are 3 different kinds of employees, there are 3 different
line formats one for each category of employee, these are:
C 1234 Sam Jones Salesman 45000.00 10.00 7000.00 8500.00
S 2312 Larry Smith Manager 54000.00
H 3212 Sally Smith Decorator 6.50 Y 43.50
Data lines containing Commission based employees begin with a C, Salaried an S , and
Hourly an H.
• Lines that begin with C indicate commission earning employees, These lines
contain the employee’s id, first and last name, title, base salary, commission
rate, commission threshold, and current sales.
• Lines that begin with S indicate salaried employees, these lines contain the
employee’s id, first and last name, title, and salary
• Lines that begin with H are for hourly employees, each line contain the
employee’s id, first and last name, title, hourly rate, a Y or N indicating if they
can earn overtime, and the hours worked this pay period
o You must read the first character of each line to determine what kind
of employee is being processed, and then read the rest of the data
o once the data is read you need to insert an employee object of the right
type into your array
• Reading a line of employee data can be accomplished by making multiple
calls to scanner methods to extract each individual piece of data
• REMEMBER: depending of the version of Java you have installed, when
reading a line of data that ends with a number, class Scanner may not
clear the new line character, if this happens we have to have a dummy
read input.nextLine() to extract it.
Testing Tip:
Begin by writing the input loop, read each line of input, and immediately print out
the information read.. this will allow you to validate your input
As each line of data is read, create an instance of the correct type of employee, then
insert it into your array. The array will accept values of type employee, when an
object of type Salaried, Hourly, or CommissionBased is placed into the array, it will
be “upcast” to type Employee automatically.
3. Once all of the employees’ data has been read, and inserted into the array, you
will need to sort the array. You may use any sorting algorithm you wish,
including the bubble sort.
4. Finally, it is time to calculate pay, and print the report.
i. For each employee in your array, loop through all elements
applying the calculatePay() method to each
ii. Print the report title, and the column headings for commission
based employees.
iii. You will begin looping through all of the employees in your array
iv. While the employee type of the employee retrieved is “C”
1. For each employee call the print() method to print out the
object contents.
2. add this employees total Pay to the total pay for all
employees of this type
v. When an employee of type hourly, is found, Print the total pay for
the previous type, skip a few lines and then print column headings
for hourly employees
vi. While the employee type of the employee is “H”
1. For each employee call the print() method to print out the
object contents.
2. add this employees total Pay to the total pay for all
employees of this type
vii. When an employee of type salaried is retrieved, Print the total pay
for the previous type, skip a few lines then print column headings
for salaried employees
1. For each employee call the print() method to print out the
object contents.
2. add this employees total Pay to the total pay for all
employees of this type
Once all employees are retrieved print the total pay for salaried
employees, and your program is finished.
Printing the report
The report will be divided in to 3 sections based on the three employee types, with the
employee data displayed in a columnar format with column headings (use the printf
method). It will have the general format:
Commission Based Employees:
First Last
Name Name
Title Employee
ID
Commission Current
Rate
Sales
Salary
Total
Pay
Each section should display the information unique to each employee type, and NOTICE
we are conveniently forgetting about taxes, and deductions. Also your report should
have a title, and for each section you should print the “grand total” of the pay due
employees of that type.
What to submit:
Your 5 java files, submitted in a single ZIP file:
Employee.java
Salaried.java
Hourly.java
Comission.java
TesterClass.java : This is what every you call the application class that contains MAIN
S 2312 Larry Smith Manager 54000.00
H 3985 Ruddy Blaire Packer 8.00 Y 88.00
C 1234 Sam Jones Salesperson 45000.00 10.00 7000.00 10000.00
H 3212 Sally Smith Decorator 6.50 Y 92.50
C 1422 Brett Kelly Salesperson 29000.00 10.00 7000.00 6000.00
H 3665 Slim Pickens Packer 7.00 N 87.00
C 1187 Homer Berns Salesperson 32000.00 8.50 5000.00 5500.00
S 2543 Lester Lovejoy TasteTester 32000.00
C 1765 Betty Davis Salesperson 50000.00 9.00 6000.00 6000.00
S 2134 Waylan Smithers AdvertisingExec 50000.00
H 3333 Hector Sanchez Baker 9.00 Y 100.00
S 2111 Marge Thomas Secretary 24000.00
C 1111 John Perry Salesperson 45000.00 10.00 7000.00 9000.00
S 2776 Michael George Manager 50000.00
C 1654 Moe Bundy Salesperson 30000.00 7.00 6000.00 4000.00
S 2887 Montgomary Bundy VicePresident 88000.00
H 3987 Clara Bell Filler 8.00 Y 90.00
S 2666 Ian Andrews Designer 33000.00
C 1222 Kelly Miller Salesperson 48000.00 8.50 5000.00 4500.00
S 2098 Elizabeth Hughes Secretary 25000.00
C 1322 Peter Davis Salesperson 37000.00 9.00 7500.00 8500.00
S 2768 Lisa Paul TasteTester 27000.00
H 3999 Dexter Alfonzo Baker 7.50 N 85.00
C 1333 Bart Simpson Salesperson 40000.00 8.50 8000.00 91000.00
H 3112 Earl Clapper Decorator 7.50 Y 80.00
C 1238 Karl Arbogast Salesperson 38000.00 8.00 6000.00 7200.00
H 3444 Lily Millhouse Filler 6.75 N 81.00
S 2099 Marty Grimm Designer 32000.00
H 3564 Ivey Nutella Decorator 7.00 N 80.00
H 3215 Robert SideShow Baker 8.25 N 80.00

Purchase answer to see full
attachment

Order your essay today and save 10% with the discount code ESSAYHSELP