1. Employee class diagram. The method raiseSalary(percent)increases the salary by the given percentage. Write the Employeeclass.
(Note: requirement language is java)
The test driver to test Employee class.
public class TestMain {
public static voidmain(String[] args) {
// Testconstructor and toString()
Employee e1 = new Employee(8, "Peter", "Tan", 2500);
System.out.println(e1); // toString();
// TestSetters and Getters
e1.setSalary(999);
System.out.println(e1); // toString();
System.out.println("id is: " + e1.getID());
System.out.println("firstname is: " + e1.getFirstName());
System.out.println("lastname is: " + e1.getLastName());
System.out.println("salary is: " + e1.getSalary());
System.out.println("name is: " + e1.getName());
System.out.println("annual salary is: " + e1.getAnnualSalary()); //Test method
// TestraiseSalary()
System.out.println(e1.raiseSalary(10));
System.out.println(e1);
}
ExpectedOutput:
Employee[id=8,name=PeterTan,salary=2500]
Employee[id=8,name=PeterTan,salary=999]
id is: 8
firstname is: Peter
lastname is: Tan
salary is: 999
name is: Peter Tan
annual salary is: 11988
1098
Employee[id=8,name=PeterTan,salary=1098]
1. Employee class diagram. The method raiseSalary(percent) increases the salary by the given percentage. Write the Emplo
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
1. Employee class diagram. The method raiseSalary(percent) increases the salary by the given percentage. Write the Emplo
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!