public static int calculateBSA(double height, double grams) {
double weightforBmi = convertGramsToPounds(grams);
return (int) Math.sqrt(((convertCentimeterToInches(height) * weightforBmi)/3131));
}
這裏是我的代碼轉換釐米英寸和克到磅。BSA計算結果我零
private static double convertCentimeterToInches(double height) {
return (Math.round((height/2.54) * 100)/100);
}
public static int convertGramsToPounds(double grams) {
double gramsToPoundUnit = .00220462262;
double pounds = (grams * gramsToPoundUnit);
return (int)(Math.round(pounds * 100)/100);
}
BSA計算結果我總是Zero
。我是否正確地在BSA內部完成Math.sqrt。