Java Max Age - tcs java UI

public class Employee{


      public int id;


      public String name;


      public double age;


      public Employee(int id,String name,double age){


          this.id=id;


          this.name=name;


          this.age=age;
    }
}


 


==================================================================================================


 


Solution.java
==================================================================================================


public class Solution{


public static Employee getEmployeeWithMaxAge(Employee e1,Employee e2,Employee e3){


      if((e1.age>e2.age)&&(e1.age>e3.age))


          return e1;


      else if((e2.age>e1.age)&&(e2.age>e3.age))


          return e2;


      else


          return e3;


      }


public static void main(String[] args){


      Employee e1=new Employee(1,"aaa",22);


      Employee e2=new Employee(2,"bbb",33);


      Employee e3=new Employee(3,"ccc",44);


      Employee e=Solution.getEmployeeWithMaxAge(e1,e2,e3);


    System.out.println(e.id+" "+e.name+" "+e.age);


      }


}


Comments

Popular Posts