输入身高判断其标准体重

import java.util.*;
import java.text.DecimalFormat;
class StdWeight{
static double forMale(double h){
return (h-100)*0.9;
}
static double forFemale(double h){
return (h-100)*0.9-2.5;
}
}
public class Standard{
public static void main(String[] s){
Scanner reader=new Scanner(System.in);
System.out.println("请输入你的身高(cm)");
double h=reader.nextDouble();
DecimalFormat df=new DecimalFormat("0.00");
System.out.println("请选择性别:1.男 2.女");
int choice=reader.nextInt();
if (choice==1)
System.out.println("标准体重为"+df.format(StdWeight.forMale(h))+"公斤");
else if (choice==2)
System.out.println("标准体重为"+df.format(StdWeight.forFemale(h))+"公斤");
else
System.out.println("输入错误,请重新输入");

}
}












你可能感兴趣的:(java)