这是我的BMI计算器,但错误"符号' showValue()'无法找到",我是否需要在main方法或showCategory(showValue())的括号中添加任何变量?
{
double bmi = bmi1.showValue();
System.out.println("Your BMI index:" + bmi + "。");
String x = bmi1.showCategory(showValue()); //error comes out from here
System.out.println("Your BMI level:" + x);
}
我的第一堂课"计算器"
class Calculator
{
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
System.out.println("You're Height(cm)");
String str1 = br.readLine();
System.out.println("You're Weight(kg)");
String str2 = br.readLine();
double height = Double.parseDouble(str1);
double weight = Double.parseDouble(str2);
BMI bmi1 = new BMI();
bmi1.setHeight(height);
bmi1.setWeight(weight);
double h = bmi1.getHeight();
double w = bmi1.getWeight();
System.out.println("Your height is:" + h + "cm。" + "Your weight is:" + w + "kg。");
double bmi = bmi1.showValue();
System.out.println("Your BMI index is:" + bmi + "。");
String x = bmi1.showCategory(showValue());
System.out.println("Your BMI level is:" + x);
}
}
我的第二课" BMI",
public class BMI
{
double height;
double weight;
double getHeight()
{
return height;
}
double getWeight()
{
return weight;
}
void setHeight(double h)
{
height = h;
}
void setWeight(double w)
{
weight = w;
}
double showValue()
{
double bmi = weight / ((height / 100) * (height / 100));
return bmi;
}
double showCategory是变量的BMI级别列表,
在括号之间更改了许多值,但错误仍然存在, 我想知道我应该怎么做才能运行,