Question
I need to create a test app for the following program that also creates two Employee objects and displays each objects yearly salary, then gives
I need to create a test app for the following program that also creates two Employee objects and displays each objects yearly salary, then gives each Employee a 10% raise and display each Employees yearly salary again.
public class Employee { //Declare instance variables private String lastName, firstName; private double monthlySalary; //Include constructor public Employee(String lastName, String firstName, double monthlySalary, String theLastName, String theFirstName, double theMonthlySalary){ theLastName = lastName; theFirstName = firstName; theMonthlySalary = monthlySalary; } //Provide get method for name and salary public String getFirstName() { return firstName; }
public String getLastName() { return lastName; }
public double getMonthlySalary() { return monthlySalary; }
//Provide set method for name and salary public void setFirstName(String s) { firstName = s; }
public void setLastName(String s){ lastName = s; }
public void setMonthlySalary(double v){ if (v<=0) { monthlySalary = v; } }
//Display information to user public void display() { System.out.printf("First name: %s ", getFirstName()); System.out.printf("Last name: %s ", getLastName()); System.out.printf("Monthly salary: %.2f ", getMonthlySalary()); System.out.printf("Yearly Salary: %.2f ", 12.0 * getMonthlySalary());
System.out.println(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started