【发布时间】:2015-09-27 00:00:49
【问题描述】:
public int maxRate(int maxRate)
{
maxRate = 220 - age;
return maxRate;
}
// calculate target rate
public String targetRate(int targetRateMin, int targetRateMax, String targetRate)
{
targetRateMin = (age * (1/2));
targetRateMax = (age * (17/20));
targetRate = (targetRateMin + "-" + targetRateMax);
return targetRate;
}
// display message
public void displayMessage()
{
System.out.printf("Name: %s %s"
+ "\n Age: %d"
+ "\n Target Heart Rate: %s"
+ "\n Maximum Heart Rate: %d"
, getFirstName(), getLastName(), calculateAge(age), targetRate(), maxRate());
}
当我尝试在我的 printf 语句中使用 targetRate() 和 maxRate 时,我很困惑为什么会出现错误(我收到红色波浪状的东西告诉我添加我不明白的东西) .是我的方法不对还是怎么回事?
【问题讨论】:
-
请显示您的错误/异常消息。此外,在您的 printf 格式字符串中将
\n更改为%n。 -
你的方法:
public int maxRate(int maxRate);你的方法调用:maxRate()...我真的想知道问题出在哪里。