当我打印消息的内容时,它总是让我“体重过轻”,尽管 displaybmi 不 <19
public String BMImessage(){
SharedPreferences customSharedPreference = getSharedPreferences(
"myCustomSharedPrefs", Activity.MODE_PRIVATE);
String Height = customSharedPreference.getString("heightpref", "");
String Weight = customSharedPreference.getString("weightpref", "");
float weight = Float.valueOf(Weight);
float height = Float.valueOf(Height);
float displaybmi = weight/(height*height);
if (displaybmi <19)
message = "Underweight" ;
else if (displaybmi >=19 && displaybmi <=25)
message = "Desirable Weight";
else if (displaybmi >=26 && displaybmi <=29)
message = "Overweight" ;
else if (displaybmi >=30 && displaybmi <=40)
message = "Obese";
else if (displaybmi >40)
message = "Extremely Obese" ;
return message;
}