Question: Design a class named Employee ( Employee.java ) to represent an employee. The class contains: ? Two private String data fields named firstName and lastName
Design a class named Employee (
Employee.java
) to represent an employee. The class
contains:
?
Two private String data fields named
firstName
and
lastName
for the first name and
last name of the employee.
?
A private double data field named
monthlySalary
for the monthly salary of the
employee.
?
A public no-argument constructor that creates a default employee.
?
A public constructor that creates an employee with the specified
firstName
,
lastName
, and
monthlySalary
.
?
The public accessor and mutator methods for
firstName
,
lastName
, and
monthlySalary
.
Draw the UML diagram (
EmployeeUML.docx
) for the class and then implement the
class. Write a test program (
EmployeeTest.java
) that creates two Employee objects and
display each employees monthly salary and yearly salary. Then give each employee a
10% salary increase by invoking the
setMonthSalary()
method for each Employee
object and finally display each employees monthly salary and yearly salary again. The
output should look exactly like the following:
Before the 10% salary increase:
John Does monthly salary is $3,000 and his yearly salary is $36,000.
Jane Does monthly salary is $4,000 and her yearly salary is $48,000.
After the 10% salary increase:
John Does monthly salary is $3,300 and his yearly salary is $39,600.
Jane Does monthly salary is $4,400 and her yearly salary is $52,800.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
