0

Java クラスに取り組んでいると、この式が 0 に評価されるため、気が狂ってしまいます。double に評価してから、最も近い 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;


}
4

2 に答える 2