//计算公式:BMI = weight / (height*height) 即(体重公斤数)除以(身高米数的平方)
public static String getBMI(Double weight, Double height) {
double BMI = weight / (height * height / 10000 );
return String.valueOf(Math.round(BMI * 100) / 100.0);
}
测试数据
public static void main(String[] args) {
double weight = 50.5;
double height = 166;
String mb = BaseCtrl.getBMI(weight,height);
System.out.println(mb);
}
结果: