- package prac5;
- public class EmployeeDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Employee e1 = new Employee(1, "abc", 20000.00, "AST", "MUM");
- Employee e2 = new Employee(2, "def", 25000.50, "ITA", "DEL");
- Employee e3 = new Employee(3, "ghi", 30000.00, "ITA", "MUM");
- Employee e4 = new Employee(4, "jkl", 27000.00, "ASE", "CHN");
- Employee e5 = new Employee(5, "mno", 53000.00, "SE", "HYD");
- Employee[] emps = { e1, e2, e3, e4, e5 };
- Employee withupdatedSalary[] = EmployeeDemo.incrementSalaryofEmployees(emps);
- for (Employee newEmpl : withupdatedSalary)
- { System.out.println(newEmpl.getEmpId() + " " + newEmpl.getEmpName() + " " + newEmpl.getGrade() + " " + newEmpl.getLocation() + " Updated Salary: " + newEmpl.getSalary()); }
- int empcount = numberOfEmployees(emps, "MUM");
- System.out.println("Number of Employees in Mumbai location is " + empcount);
- }
- public static int numberOfEmployees(Employee[] emp, String st)
- {int count=0;
- for(int i=0;i<emp.length;i++)
- {
- if(emp[i].getLocation().equalsIgnoreCase(st))
- {
- count++;
- }
- }
- return count;
- }
- public static Employee[] incrementSalaryofEmployees(Employee[] emp)
- {int count=0;
- for(int i=0;i<emp.length;i++)
- {
- if(emp[i].getGrade().equalsIgnoreCase("ASE") && emp[i].getGrade().equalsIgnoreCase("SE") && emp[i].getGrade().equalsIgnoreCase("ITA")&&emp[i].getGrade().equalsIgnoreCase("AST"))
- {
- count++;
- }
- }
- for(int i=0;i<emp.length;i++)
- {
- // if(emp[i].getGrade().equalsIgnoreCase("ASE") && emp[i].getGrade().equalsIgnoreCase("SE") && emp[i].getGrade().equalsIgnoreCase("ITA")&&emp[i].getGrade().equalsIgnoreCase("AST"))
- if(emp[i].getGrade().equalsIgnoreCase("ASE"))
- {
- emp[i].setSalary(emp[i].getSalary()+emp[i].getSalary()*30/100);
- }
- if(emp[i].getGrade().equalsIgnoreCase("SE"))
- {
- emp[i].setSalary(emp[i].getSalary()+emp[i].getSalary()*50/100);
- }
- if(emp[i].getGrade().equalsIgnoreCase("ITA"))
- {
- emp[i].setSalary(emp[i].getSalary()+emp[i].getSalary()*70/100);
- }
- if(emp[i].getGrade().equalsIgnoreCase("AST"))
- {
- emp[i].setSalary(emp[i].getSalary()+emp[i].getSalary()*90/100);
- }
- }
- return emp;
- }
- }
[text] prac5
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: