Question: In java Define a class named Employee and save the class in a file named Employee.java the two java files should be saved in the

In java Define a class named Employee and save the class in a file named Employee.java

the two java files should be saved in the same folder This class has four data fields:

name: String

hoursWorked: double

hourlyPayrate: double

bonusRate: double

The class has two constructors: 1. constructor without arguments: initialize name to empty string, and all other data fields to 0.0 2. constructor with a String type arguments and three double type arguments. Use them to initialize the data fields properly The class also has:

1. getter method for each data field to return the value of the data field

2. setter method for each data field to set a new value of that data field

3. a method called calcRegularPay to calculate and return the regular salary using the following formula:

regular salary of an employee = hoursWorked * hourlyPayRate

4. a method called calcBonus to calculate and return the amount of bonus using the following formula:

bonus amount of an employee = regular salary of an employee * bonus rate

where the regular salary of an employee is the return value of the method in 3

5. a method called calcGrossPay to calculate and return the gross pay using the following formula:

gross pay of an employee = regular salary of an employee + bonus amount of the employee

where the regular salary of an employee is the return value of the method in 3 and the bonus amount is the return value of the method in 4

Then write a separate demo program to test the class. The demo program should be saved in a file named EmployeeDemo.java. In the demo program:

create an empty employee. Use setters methods to set values for all data fields. Use the three methods to calculate regular pay, bonus amount, and gross pay for the employee. Display results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!