在 Java 类上工作,这让我很抓狂,因为这个表达式的计算结果为零,我需要它计算为双精度数,然后将其四舍五入到最接近的 int。所以我想要得到的是天数是整数天,但是当我通过 java 运行它时,它评估为 0。当我通过我的计算器运行它时,它评估为正确的值。我很想修复并解释为什么我已经拥有的东西不起作用。
public int getEventDays(){
//variables
double daysCalc;
int days;
//logic
if (getStatus().equals("filling")){
//this is indented less to fit everything on one line, its not this way in
//the fractions are for unit conversion
daysCalc= Math.floor(((capacity-storage)/(inflow-outflow))*(43560)*(1/3600)*(1/24));
days = (int)daysCalc;
}
else if (getStatus().equals("emptying")){
//this is indented less to fit everything
//the fractions are for unit conversion
daysCalc=Math.floor(((storage-0)/(outflow-inflow))*(43560)*(1/3600)*(1/24));
days = (int)daysCalc;
}
else{
days = -1;
}
return days;
}