public class Student {
private String name;
private int id;
private int age;
private int weight;
private int height;
public Student(String name, int id, int age, int weight, int height) {
this.name = name;
this.id = id;
this.age = age;
this.weight = weight;
this.height = height;
}
public void display() {
System.out.println(this.name);
System.out.println(this.id);
System.out.println(this.age);
System.out.println(this.weight);
System.out.println(this.height);
}
public int get_age() {
return this.age;
}
public static void main(String[] args) {
Student[] info = {new Student("Bun Tun", 00001, 18, 68, 149),
new Student("FlukeKnub", 00002, 17, 50, 179),
new Student("BasBomba", 00003, 20, 44, 188),
new Student("GaseKiki", 00004, 21, 67, 180),
new Student("PeeJa", 00005, 15, 88, 155)};
age_average(info);
}
public static void age_average(Student[] e) {
int sum = 0;
int i = 0;
int average = 0;
while (i < e.length) {
sum = sum + e[i].get_age();
i = i + 1;
}
average = sum / e.length;
System.out.println(average);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น