Question: need help formatting output, the codes what is should do i just cant get it to print the way the question is asking, please dont
need help formatting output, the codes what is should do i just cant get it to print the way the question is asking, please dont change anything but what is necessary to format
Employee class representing an employee with a first name, last name, and monthly salary.
This class includes methods for getting and setting these fields and
for representing the employee as a formatted string.
@author
@version
public class Employee
Step : Private instance variables
private String firstName;
private String lastName;
private double monthlySalary;
Constructor to initialize the Employee with first name, last name, and monthly salary.
Ensures that the monthly salary is nonnegative.
@param firstName The first name of the employee.
@param lastName The last name of the employee.
@param monthlySalary The monthly salary of the employee.
public EmployeeString firstName, String lastName, double monthlySalary
this.firstName firstName;
this.lastName lastName;
Step : Check salary before initializing
this.monthlySalary monthlySalary monthlySalary : ;
Step : Mutator setter methods
Sets the first name of the employee.
@param firstName The first name to set.
public void setFirstNameString firstName
this.firstName firstName;
Sets the last name of the employee.
@param lastName The last name to set.
public void setLastNameString lastName
this.lastName lastName;
Sets the monthly salary of the employee, ensuring it is nonnegative.
@param monthlySalary The monthly salary to set.
public void setMonthlySalarydouble monthlySalary
if monthlySalary
this.monthlySalary monthlySalary;
Step : Accessor getter methods
Gets the first name of the employee.
@return The first name of the employee.
public String getFirstName
return this.firstName;
Gets the last name of the employee.
@return The last name of the employee.
public String getLastName
return this.lastName;
Gets the monthly salary of the employee.
@return The monthly salary of the employee.
public double getMonthlySalary
return this.monthlySalary;
Step : toString method
Returns a formatted string representing the employee.
@return A formatted string with the employee's name and monthly salary.
@Override
public String toString
Format to match example output
return String.formats s f this.firstName, this.lastName, this.monthlySalary;
Additional method for yearly salary calculation after increase
Increases the monthly salary by and calculates the yearly salary.
@return The yearly salary after a increase.
public double getYearlySalaryWithIncrease
return this.monthlySalary ;
picture attached show the difference
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
