我想在我的CalBMI方法中进行计算体重指数的操作,这取决于CalWt和CalHt方法的输入。然后CalBMI方法将返回BMI答案。我怎么能做这样的操作?我的CalBMI中的操作
double Wt=0, Ht=0, BMI;
System.out.println("Your Weight in Kg is: " + CalWt(Wt) );
System.out.println("Your Height in meters is: " + CalHt(Ht) );
System.out.println("Your BMI is: " + CalBMI(Wt,Ht) );
}
public static double CalWt(double a){
System.out.println("Please enter your Weight in lbs: ");
double Wt=(type.nextDouble() * .454); //Converts to Kg.
return Wt;
}
public static double CalHt(double b){
System.out.println("\nPlease enter your Height in inches: ");
double Ht=(type.nextDouble() * .025); //Converts to m.
return Ht;
}
public static double CalBMI(double a, double b){
double BMI=a/(Math.pow(b, 2));
return BMI;
}
{
{{1}}
}
答案 0 :(得分:0)
请告诉我配方是否错误
public class BMI {
public static double CalWt(Scanner type) {
System.out.println("Please enter your Weight in lbs: ");
return type.nextDouble() * .45359;
}
public static double CalHt(Scanner type) {
System.out.println("Please enter your Height in inches: ");
return type.nextDouble()* .025;
}
public static double CalBMI() {
Scanner type = new Scanner(System.in);
return CalWt(type) / Math.pow(CalHt(type),2);
}
public static void main(String[] args) {
System.out.println(CalBMI());
}
}