如何获取java金额的输出

时间:2019-05-21 09:28:33

标签: java

需要有关如何解决此简单Java程序的帮助。我还需要输出其余的内容。 amount2来自查询,我确实将查询的输出为200。因此它将简化以使其易于理解。

这是我查询的输出200。

String rs2 = " SELECT EMP_NO,SUM(AMOUNT) AS AMOUNT,DUE_DATE FROM CFV_CHARGES WHERE EMP_NO = '"+emp_no+"' AND TO_DATE(DUE_DATE) > '15-JUN-19' GROUP BY EMP_NO,DUE_DATE ";
ResultSet result2 = stmt.executeQuery(rs2);  

amount1 = -230;
int remaining = 0;
int total = 0;

while(result2.next()){

    //output from my query is 200
    int amount2 = Integer.parseInt(result2.getString("AMOUNT")); 

    //amount2 is my base amount

    //when getting the breakdown, it will check on the amount2 and the remaining would output.

    if(amount1 > remaining){

        //
        System.out.println(amount1);
    }else{
        System.out.println(remaining);
    }

    remaining = remaining - amount1;
}

实际输出为

金额

-200
-30

0 个答案:

没有答案