Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class named Employee and save the class in a file named Employee.java This class has four data fields: name: String hoursWorked: double hourlyPayrate:

Define a class named Employee and save the class in a file named Employee.java 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.

Notes:

1. the two java files should be saved in the same folder

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

5. What makes employee relations so similar in Sweden and Finland?

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago