public class Student {
private String name;
private float weight;
private float high;
private int age;
private int ID;
public Student(String name , int weight , int high , int age , int ID ) {
this.name = name ;
this.weight = weight;
this.high = high;
this.age = age;
this.ID = ID;
}
public float get_high(){
return this.high;
}
public float get_weight(){
return this.weight;
}
public void display() {
System.out.println( "NAME: "+this.name);
System.out.println( "WEIGHT:"+this.weight+" kg.");
System.out.println( "HIGH:"+this.high+" cm.");
System.out.println( "AGE :"+this.age+" years old");
System.out.println( "ID :"+this.ID);
}
public static void main(String[] args) {
Student[] std = {new Student("Park",40,160,18,1),
new Student("Nani",50,180,19,2),
new Student("Pepe",80,185,20,3),
new Student("Giggs",70,160,18,4),
new Student("Laws",85,155,18,5)
};
int index = 0;
while(index<std.length){
std[index].display();
System.out.println("BMI "+calculation_of_bmi (std[index] ));
index = index + 1;
}
System.out.println("Number of students that have bmi more than 25 is "+count_bmi(std));
}
public static float calculation_of_bmi (Student Student){
float highM = Student.get_high() / 100;
float bmi = Student.get_weight()/(highM*highM);
return bmi ;
}
public static int count_bmi(Student[] student){
int index = 0 ;
int count = 0 ;
while(index<student.length){
if(calculation_of_bmi (student[index])>25){
count +=1 ;
}
index = index + 1 ;
}
return count ;
}
}
private String name;
private float weight;
private float high;
private int age;
private int ID;
public Student(String name , int weight , int high , int age , int ID ) {
this.name = name ;
this.weight = weight;
this.high = high;
this.age = age;
this.ID = ID;
}
public float get_high(){
return this.high;
}
public float get_weight(){
return this.weight;
}
public void display() {
System.out.println( "NAME: "+this.name);
System.out.println( "WEIGHT:"+this.weight+" kg.");
System.out.println( "HIGH:"+this.high+" cm.");
System.out.println( "AGE :"+this.age+" years old");
System.out.println( "ID :"+this.ID);
}
public static void main(String[] args) {
Student[] std = {new Student("Park",40,160,18,1),
new Student("Nani",50,180,19,2),
new Student("Pepe",80,185,20,3),
new Student("Giggs",70,160,18,4),
new Student("Laws",85,155,18,5)
};
int index = 0;
while(index<std.length){
std[index].display();
System.out.println("BMI "+calculation_of_bmi (std[index] ));
index = index + 1;
}
System.out.println("Number of students that have bmi more than 25 is "+count_bmi(std));
}
public static float calculation_of_bmi (Student Student){
float highM = Student.get_high() / 100;
float bmi = Student.get_weight()/(highM*highM);
return bmi ;
}
public static int count_bmi(Student[] student){
int index = 0 ;
int count = 0 ;
while(index<student.length){
if(calculation_of_bmi (student[index])>25){
count +=1 ;
}
index = index + 1 ;
}
return count ;
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น