JAVA: BMI 计算器使用 [英] JAVA: BMI Calculator using
本文介绍了JAVA: BMI 计算器使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 java 非常陌生,试图使用构造函数、公共实例方法和 toString 方法构建一个简单的 BMI 计算器.
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.
谢谢:)
推荐答案
你已经有了一个代码,所以我只想提一下 BMI 是体重(公斤)除以身高(米)平方
You already have a code so I'll just mention that BMI is weight (in kg) divided by height (in m) squared
这篇关于JAVA: BMI 计算器使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文