madhawaseeeee

test

Sep 13th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. public class Test {
  2.  
  3.     Employee[] x = new Employee[3];
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Test m = new Test();
  8.  
  9.         m.createEmployees();
  10.  
  11.     }
  12.  
  13.     public void createEmployees() {
  14.         x[0] = new Employee();
  15.         x[1] = new Employee();
  16.         x[2] = new Employee();
  17.  
  18.         x[0].setName("nimal");
  19.         x[0].setSalary(5000);
  20.         x[0].setEmployee_number(2);
  21.  
  22.         x[1].setName("sunil");
  23.         x[1].setSalary(70000);
  24.         x[1].setEmployee_number(1);
  25.  
  26.         x[2].setName("kamal");
  27.         x[2].setSalary(80000);
  28.         x[2].setEmployee_number(3);
  29.  
  30.         for (int i = 0; i < 3; i++) {
  31.  
  32.             if (x[i].getSalary() > 10000) {
  33.  
  34.                 double s = x[i].getSalary() * 0.9;
  35.  
  36.                 System.out.println(x[i].getName() + "'s salary in august is " + s);
  37.  
  38.             } else {
  39.  
  40.                 System.out.println(x[i].getName() + "'s salry is " + x[i].getSalary());
  41.             }
  42.  
  43.         }
  44.  
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment