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 StdWeightTest{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
DecimalFormat df=new DecimalFormat("0.00");
System.out.println("请输入您的身高");
double height=sc.nextDouble();
System.out.println("请选择您的性别:1 男 2 女");
int sex=sc.nextInt();
String weight1,weight2;
weight1=df.format(StdWeight.forMale(height));
weight2=df.format(StdWeight.forFemale(height));
if(sex==1)
System.out.println("标准体重="+weight1+"公斤");
else if(sex==2)
System.out.println("标准体重="+weight2+"公斤");
else
System.out.println("您输入的数字不对,请重新输入");
}
}
static double forMale(double h){
return ((h-100)*0.9);
}
static double forFemale(double h){
return ((h-100)*0.9-2.5);
}
}
public class StdWeightTest{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
DecimalFormat df=new DecimalFormat("0.00");
System.out.println("请输入您的身高");
double height=sc.nextDouble();
System.out.println("请选择您的性别:1 男 2 女");
int sex=sc.nextInt();
String weight1,weight2;
weight1=df.format(StdWeight.forMale(height));
weight2=df.format(StdWeight.forFemale(height));
if(sex==1)
System.out.println("标准体重="+weight1+"公斤");
else if(sex==2)
System.out.println("标准体重="+weight2+"公斤");
else
System.out.println("您输入的数字不对,请重新输入");
}
}