วันเสาร์ที่ 14 พฤศจิกายน พ.ศ. 2558

Lab8_Find_>_25


public class Student {
 private String name;
 private int idNO;
 private int age;
 private int weight;
 private int height;

 public Student(String name,int idNO,int age,int weight,int height){
 this.name = name;
 this.idNO = idNO;
 this.age = age;
 this.height = height;
 this.weight = weight;
}
public int get_age(){
return this.age;
}

public void display(){
 System.out.println("Name :"+this.name+" ID NO :"+this.idNO+" Age : "+this.age+" Weight : "+this.weight+" Height : "+this.height);
}

public static void main(String[] arg){
  Student[] a =  {new Student("James",58001,13,177,90),
        new Student("Jane",58002,15,140,60),
        new Student("John",58003,17,156,54),
        new Student("Jonas",58004,20,188,70)};
 int i =0;
    while(i<a.length){
     a[i].display();
     System.out.println("this "+find_more_25(a,i)+" older than 25");
     i=i+1;
    }
 }

public static String find_more_25(Student[] a,int i){
String n="";
if(a[i].get_age()>25){
n=("one");
}else{
    n=("one not");
}
return n ;
}
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น