In: Computer Science
This class contains the main method. In this class you should:
Code:
====
public class EmployeeDemo {
public static void main(String[] args) {
Employee emp = new Employee("ABC",
"BCD", 10000.00);
System.out.println("Employee name:
"+emp.getName());
System.out.println("Employee job
title: "+emp.getJobTitle());
System.out.println("Employee
salary: "+emp.getSalary());
System.out.println("Calling salary
raise method with 25%");
emp.raiseSalary(25.0);
System.out.println("Employee salary
after 25% hike: "+emp.getSalary());
}
}
class Employee{
private String name;
private String jobTitle;
private double salary;
public Employee(String name, String jobTitle, double
salary) {
super();
this.name = name;
this.jobTitle = jobTitle;
this.salary = salary;
}
public String getName() {
return name;
}
public String getJobTitle() {
return jobTitle;
}
public double getSalary() {
return salary;
}
public void raiseSalary(double perc) {
this.salary =
(perc*salary/100)+salary;
}
}
output:
=====