I'm coding a fairly simple program that simply outputs 2 employee's Names, their salary, and a 10% raise to that salary. I have 2 issues: 1) The salary prints as '$0.000000' 2) Ii cannot get the raise method to work properly
Here's my code:
public class Employee {
// instance variable
private String name;
private String lastName;
private double salary;
// setters
public String getLastName() { return lastName; }
public String getName() { return name; }
public double getSalary() { return salary; }
public void raise(double raise) { salary = salary + (salary * .1); }
// getters
public Employee(String name, String lastName, double salary) {
this.name = name;
this.lastName = lastName;
if (salary > 0.0) {
this.salary = salary;
}
}
}
public class EmployeeTest {
public static void main(String[] args) {
Employee raise1 = new Employee("Betty", "Jones", 4000.0);
Employee raise2 = new Employee("Sally", "Mae", 6000.0);
// Print statements for the employee's name and salary
System.out.printf("Employee #1\nFirst Name: %s\nLast Name: %s\n\n" + "Salary: $%f", raise1.getName(), raise1.getLastName(), raise1.getSalary());
// THIS IS WHERE I'M HAVNG TROUBLE
System.out.printf("Her raise will be: %d", raise1.raise(salary));
System.out.printf("Employee #1\nFirst Name: %s\nLast Name: %s\n\n" + "Salary: %f", raise1.getName(), raise1.getLastName(), raise1.getSalary());
raise2.raise(salary);
}
}
Thanks in advance for the help!