Practical Activity 1 2024
Practical Activity 1 2024
Problem Statement:
Best Buys Furniture Warehouse is a company that makes and sells quality
furniture. They have 3 types of employees:
• Hourly employees -get paid an hourly wage, but if they work more than
40 hours per week, the excess is paid at “time and a half”.
• Salaried employees -get paid their salary, no matter how many hours
they work.
• Managers -are salaried employees who get paid a salary and a bonus.
You are required to develop a system that will store employees details and
Calculate their weekly pay.
1.Using the NetBeans IDE, create a project and name it Employee Salary
2. Create a Java package naming it vut and in it create a Java class Employee.
▪ The Employee class should store the following as attributes: the name of
an employee, the cell phone number, employee type- salaried,
manager and hourly, annual salary, hourly wage, weekly bonus
▪ Code the default and parametrized constructor for the class.
▪ Code mutators and accessors for all the attributes validating user
input. The name of an employee cannot have less than 3 characters, the
cell phone number must have 10 digits and begin with zero (0). Annual
salary, weekly bonus, and hourly wage cannot be negative.
• Create a method named calculatePay to receive as a parameter the
hours worked by an employee and calculate the weekly pay for the
employee.
o The weekly pay for hourly employees is calculated by multiplying
the hours worked by the employee times the hourly wage, but if
they work more than 40 hours per week, the excess is paid at “time
and a half”.
2
o The annual salary is used to calculate the weekly pay for salaried
employees and managers no matter how many hours they work.
But managers also get a weekly bonus on top of their weekly
salary.
• Code the toString method to display the name, employee type, cell #,
the annual salary, and the hourly wage of an employee.
Figure 1
3. Use the GUI shown in Figure 2 for the system, naming the class of the form,
EmployeeForm as shown in Figure 1. The GUI should be stored in the
vut.gui package. Rename the textFields, radio buttons and buttons
appropriately.
Figure 2
3
▪ Display the created object by calling the toString method of the
Employee class together with the calculated weekly pay for the employee
as in Figure 3, Figure 4 and Figure 5.
Figure 3
Figure 4
4
Figure 5
6. Note that when the hourly employee option button is selected, the
annual salary text field and the weekly bonus text field are not visible and
when the salaried option button is selected, the hourly wage text field and
the weekly bonus text field are not visible and when the manager option
button is selected, the hourly wage text field is not visible.
Code the ActionPerformed event procedures of the option buttons accordingly.