本文介绍了JAVA:BMI计算器使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我非常新的java尝试使用构造函数,公共实例方法和toString方法构建一个简单的BMI计算器。public class BMI {
pre>
public BMI(String name,double height,double weight){
}
public String getBMI(){
return(weight / height);
}
public String toString(){
return name +is+ height +tall and is+ weight +
and BMI为+ getBMI();
}
public static void main(String [] args){
}
我真的不知道我在做什么,所以所有的帮助是赞赏。如果您知道如何完成此操作,并且可以向我展示一种可以演示如何使用它将更加感激的主要方法。
谢谢:)
解决方案您已经有一个代码,所以我只要提到BMI是重量(以kg为单位)除以高度(以m为单位)平方
I am very new to java trying to build a simple BMI calculator using a constructor, a public instance method and a toString method.
public class BMI { public BMI(String name, double height, double weight){ } public String getBMI() { return (weight/height); } public String toString() { return name + "is" + height + "tall and is " + weight + "and has a BMI of" + getBMI() ; } public static void main(String[] args) { }
i don't really know what i'm doing, so all help is appreciated. If you know how to complete this and can show me a main method which can demonstrate how to use it that would be even more appreciated.
thanks :)
解决方案You already have a code so I'll just mention that BMI is weight (in kg) divided by height (in m) squared
这篇关于JAVA:BMI计算器使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!