Program 3
Program 3
in the following class diagram. The method raiseSalary (percent) increases the salary by the given percentage.
Develop the Employee class and suitable main method for demonstration.
Aim: Demonstrating creation of java classes, object, declaration and initialization of variables
import java.util.Scanner;
public class Employee_Sal_Inc {
private int id;
private String name;
private double salary;
@Override
public String toString() {
return "Employee{" +
"id=" + id +
", name='" + name + '\'' +
", salary=" + salary +
'}';
}
}
}
Output:
Employee before salary increase: Employee{id=1, name='John', salary=50000.0}
Enter the percentage increment for the employee:
25
Employee after salary increase: Employee{id=1, name='John', salary=62500.0}