LabTest2 301
LabTest2 301
Note: You can have only one Scanner object for this project, and that scanner should be closed
before the end of the program.
Contractor
o firstName: to be read from the user
o lastName: to be read from the user
o hourly rate: to be read from the user
o hours per week: to be read from the user
o tax: 15% (that is, 0.15)
Regular
o firstName: to be read from the user
o lastName: to be read from the user
o annual salary: to be read from the user
o deduction: 17% (that is, 0.17)
Write an interface Employee with an attribute that represents the name of the company and with
abstract methods to read details of an employee, process the payroll and to print the details.
Name of the company should be your name plus the word tech (Example: RejaulTech).
Also write Regular and Contractor classes that use Employee interface. These classes represent
regular and contractor employees.
The constructor for your Regular and Contractor classes will set the tax rate and deduction rate
accordingly. The method that reads details from the user will read details like employee’s name,
annual salary, hourly rate, hours per week etc. as required.
The method that does the payroll calculation should return the calculated amount. The print
method should get the return value of calculation method as a parameter.
Payroll class will have an array of Employee objects as its attributes. This class will do two
things:
1. add employees: Ask the user to enter the type of employee – Regular or Contractor. If the
user opts some other option other than Regular or Contractor, print an error message.
You need to repeat the process of reading the type of employee until you get a valid input
- Regular or Contractor. (See expected output). Read the details of the employee.
2. process payroll: This method will process the payroll for all employees and prints the
details.
PayrollTest class: In the main method, read from the user the number of employees in the
company. Then, create a Payroll object as required. With the created object, invoke methods for
adding employees and processing details.
Expected Output
To get marks, you need to define Employee interface, Contractor class, Regular class,
Payroll class and PayrollTest class.
Grading Scheme
Item Marks
Employee interface 2
Regular class 4
Contractor class 4
Payroll class 4
PayrollTest class 4
Comments (class header, provide comments wherever required) 2
Submission
Submit your source code (Employee.java, Regular.java, Contractor.java, Payroll.java and
PayrollTest.java) and the screenshot of the running program (LabTest.doc) during week 14 lab
hours in Brightspace.