Question: JAVA Write a Java class called Employee (Parts of the code is given below), which has two private fields id (int) and salary (int) and
Write a Java class called Employee (Parts of the code is given below), which has two private fields id (int) and salary (int) and three methods raise Salary(double percent), getBonus(double percent) and toString(). Write the necessary constructors and accessor methods and mutator methods, raiseSalary) method takes the percent and increases the salary on that percent. getBonus() method takes a percentas parameter and returns the bonus value as that percent of the salary.toString method should return the id and the salary. For example, if you print out the object with id 123 and width salary of $4000 than it should print Employee 123 has a salary of $4000 public class Employee private int id; public void raiseSalary (double percent) { salary = (int) ((double) salary* (1+percent)); public void getBonus (double percent) [ Write a client program called EmployeeClient that creates a Employee object called El and initialize id and salary at the time of creating the object using the constructor. Call the raise Salary method to enlarge salary by 5% and call the toString method to print the employee id and salary. Then, calculate the bonus for El of 30 of salary and print El bonus using System.out.println(). Create another object called E2 without initializing it and display the id and salary for this object. Then use the accessor/mutator methods to assign id and salary. Print the object E2 using System.out.println()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
