如何在java中获取剩余的

如何在java中获取剩余的,java,Java,我有一个java程序,将运行每15日和最后一天的一个月,我有一个样本,有2种不同类型的金额 此类型的金额来自查询,并且已按sysdate排序,这是查询的结果: 130 五百 运行程序时,它将自动从第一笔金额中扣除,剩余金额将转到第二笔金额 这是第一笔125美元 这是第二个数字100 我该怎么做?非常感谢你的帮助 //这是获取130500的查询 String getAdvanceEmployee = "SELECT AMOUNT FROM CFV_CHARGES WHERE EMP_NO = '4

我有一个java程序,将运行每15日和最后一天的一个月,我有一个样本,有2种不同类型的金额

此类型的金额来自查询,并且已按sysdate排序,这是查询的结果:

130 五百

运行程序时,它将自动从第一笔金额中扣除,剩余金额将转到第二笔金额

这是第一笔125美元

这是第二个数字100

我该怎么做?非常感谢你的帮助

//这是获取130500的查询

String getAdvanceEmployee = "SELECT AMOUNT FROM CFV_CHARGES WHERE EMP_NO = '40000124' AND TO_DATE(DUE_DATE) = '30-JUN-19' AND IS_ADVANCE = '1'";
ResultSet result1 = stmt.executeQuery(getAdvanceEmployee);


while(result1.next()){

String amount = result1.getString("AMOUNT");
//the output 130,150


//this is the query to get the 125. 

String getAdvancePayment = "SELECT AMOUNT FROM CFV_CHARGES WHERE EMP_NO = '40000124' AND TO_DATE(DUE_DATE) = '30-JUN-19' AND ENTRY_TYPE = '1'";
    ResultSet result2 = stmt1.executeQuery(getAdvancePayment);


while(result1.next()){

String amount = result1.getString("AMOUNT");
//the output will 125


    //im confused the logic itself


 }
}
查询中的金额: 130 五百

第一笔金额125 第二笔是100英镑

实际结果是:

125 -125//这个负数来自130的数量,剩余的-5将转到下一个数量,即

一百 -5 -九十五


//剩下的最后一个是-405。

你可以这样计算:

public int calculatAmountOne(int firstAmount , int secondAmount){
//in your case firstAmount = 125 , secondeAmount = 130 
int rest = firstAmount - secondeAmount ;
return rest 
}

public int calculatAmountTwo(int firstAmount , int secondAmount){
//in your case firstAmount = 100, secondeAmount = -5
int rest = firstAmount + secondeAmount ;
return rest 
}
现在,您创建了两个方法来计算两个不同的量,您可以使用它们

int restOne = calculatAmountOne(125,130) // restOne = -5 ;
int restTwo = calculatAmountTwo(100,restOne) // restTwo = 95 ;
int lastRemaining = restTwo + 500 // lastRemaining = 595

以后你应该使用你得到的数字,而不是我根据你的问题给出的数字作为例子

可以这样计算:

public int calculatAmountOne(int firstAmount , int secondAmount){
//in your case firstAmount = 125 , secondeAmount = 130 
int rest = firstAmount - secondeAmount ;
return rest 
}

public int calculatAmountTwo(int firstAmount , int secondAmount){
//in your case firstAmount = 100, secondeAmount = -5
int rest = firstAmount + secondeAmount ;
return rest 
}
现在,您创建了两个方法来计算两个不同的量,您可以使用它们

int restOne = calculatAmountOne(125,130) // restOne = -5 ;
int restTwo = calculatAmountTwo(100,restOne) // restTwo = 95 ;
int lastRemaining = restTwo + 500 // lastRemaining = 595

以后你应该使用你得到的数字,而不是我根据你的问题给出的数字作为例子

你试过什么?什么不起作用?你试过什么?什么不起作用?