获取距离 java 中 "Event" 大坝的天数

get amount of Days until a dam "Event" in java

我 运行 遇到了一个问题,它制定了一个公式来计算大坝清空或填满所需的天数。这一切都在一个名为 Dam 的 public class 中。

基本上我有:

int capacity = 3538000;  // acreFT
int storage = 1796250;   // acreFT
int inflowRate = 1050;   // cubic-FT/sec
int outflowRate = 2530;  // cubic-FT/sec

然后我发表 if-else 声明,内容如下:

if(inflow > outflow)
{
     //formula here
}
else if (outflow > inflow)
{
     //formula here
}
else
{
     return -1; // if dam inflow/outflow is equal basically, "holding."
}

我将如何处理这里的公式?如果我开始;

if(outflow > inflow)
{
     int data = outflow - inflow; // still in cubic-ft per sec
     // convert data to acresFT? using some sort of conversion variable?
     // then using new variable for the converted data * storage..?
     // then finally times by second in a day (86400 seconds, another variable established at the top of my program.)
}

这可能读起来很粗糙,但我不想在这里上传我的整个文件。

我把你的变量的意思取如下

capacity as the total volume of water it can hold
storage as the total volume of water it currently holds
inflow as volume of water flowing into the dam per second
outflow as volume of water flowing out of the dam per second 

int flow_rate_difference = 0 ;
Long dam_fill_seconds = 0;
Long dam_empty_seconds = 0;

if(inflow > outflow)
{
     //we have to calculate the amount of seconds it will take to fill the dam
     // 1 acre foot = 43560.0004435. I am taking 43560 plz use full value if you require more accuracy 
     // conversion taken from http://www.convertunits.com/from/cubic+foot/to/acre+foot

     // total capacity 3538000acrefoot
     // current capacity = total capacity - stored capacity ie (3538000-1796250) acrefoot
     // current capacity in cubic foot  (3538000-1796250)*43560
     // at the same second water is flowing into and out of dam . but if inflow is higher then that difference we have to calculate

     flow_rate_difference = inflowRate - outflowRate;
     // total sec required to fill dam is current capacity / flow_rate_difference 
     dam_fill_seconds = (3538000-1796250)*43560/flow_rate_difference ;

}
if (outflow > inflow )
{
    //time for dam to be empty

     flow_rate_difference =  outflowRate-inflowRate;
     //here we just need to take stored capacity 

     dam_empty_seconds = storage*43560/flow_rate_difference;



}