基本情報技術者試験 午後対策 JAVA⑤ BMI


class Body {
String name;
double height;
double weight;
Body(String n, double h, double w){
name = n;
height = h;
weight = w;
}
double calcBmi() {
return weight/(height*height);
}
}

public class Test {
public static void main(String[] args) {
Body name1 = new Body("情報太郎", 1.7, 53.5);
System.out.println(name1.name + "のBMI値は"
+ name1.calcBmi() + "です");
}
}