Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create a test app for the following program that also creates two Empl

ID: 3879687 • Letter: I

Question

I need to create a test app for the following program that also creates two Employee objects and displays each
object’s yearly salary, then gives each Employee a 10% raise and display each Employee’s 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();
}
  
}

Explanation / Answer

class Main {
public static void main(String[] args) {
  
Employee Employee("Nash","John",200);
Employee two = new Employee("Orton","Randy",150);
  
// printing yearly salary
System.out.printf("First employee yearly salary: %.2f ",12*one.getMonthlySalary());
System.out.printf("Second employee yearly salary: %.2f ",12*two.getMonthlySalary());
  
// incrementing by 10 percent
System.out.println(" Incrementing by 10 percent ");
one.riseSalary(10);
two.riseSalary(10);
  
// printing yearly salary after incrementing
System.out.printf("First employee yearly salary: %.2f ",12*one.getMonthlySalary());
System.out.printf("Second employee yearly salary: %.2f ",12*two.getMonthlySalary());
  
}

}

class Employee {

//Declare instance variables
private String lastName, firstName;
private double monthlySalary;
  
//Include constructor
public Employee( String theLastName, String theFirstName, double theMonthlySalary){
lastName = theLastName;
firstName = theFirstName;
monthlySalary = theMonthlySalary;
}
  
//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;
}
}
public void riseSalary(int percentage){
monthlySalary = (1+(percentage/100.0))*monthlySalary;
}
//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();
}
  
}
/*SAMPLE OUTPUT
First employee yearly salary: 2400.00
Second employee yearly salary: 1800.00

Incrementing by 10 percent

First employee yearly salary: 2640.00
Second employee yearly salary: 1980.00
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote