Please see the picture Implement a class Employee. An employee has a name (a str
ID: 3544218 • Letter: P
Question
Please see the picture
Implement a class Employee. An employee has a name (a string) and a salary (a double). Provide a constructor with two arguments public Employee(String e-npl oyeeName, double currentSalary) and methods public String getName() public double getSalary () public void raiseSalary(double byPercent) These methods return the name and salary, and raise the employee's salary by a certain percentage. Sample usage: Employee harry = new EmployeeC'Hacker, Harry", 50000); harry.raiseSalary(lO); // Harry gets a 10 percent raise Supply an EmployeeTester class that tests all methods.Explanation / Answer
public class EmployeeTester {
public static void main(String[] args) {
Employee harry= new Employee("Hacker, Harry",50000);
System.out.println("Name: "+ harry.getName());
System.out.println("Salary: "+ harry.getSalary());
//raise salary by 10%
harry.raiseSalary(10);
System.out.println("New Salary: "+harry.getSalary());
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.