-4
            String loanamount = edtamount.getText().toString();
            double doubleloanamount = Double.parseDouble(loanamount);
            String strloanamount = Double.toString(doubleloanamount);

            Log.v("doubleloanamout", strloanamount);

            String years = edtyears.getText().toString();

            double doubleyears = Double.parseDouble(years) * 12;

            String strpaymentdoubleyears =   Double.toString(doubleyears);
            Log.v("doubleyears", strpaymentdoubleyears);

            double inrate = doubleloanamount * 11 / 100;
            double monthlyrate = inrate / 12;
            double roundmonthlyrate = Math.round(monthlyrate);
            String inratefordemo = Double.toString(roundmonthlyrate);


            double Payment = (doubleloanamount
                    * Math.pow(( roundmonthlyrate) + 1, (doubleyears)) *  roundmonthlyrate)
                    / (Math.pow( roundmonthlyrate + 1, (doubleyears)) - 1);



            double roundpayment = Math.round(Payment);
            String strpayment = Double.toString(roundpayment);
            Log.v("payment", strpayment);
            edtemimonth.setText(strpayment);

我使用上面的代码来计算 EMI,但它显示 0 value.hay 我同时使用了 int 和 double 仍然它给我 0 for int 0.0 for double

4

2 回答 2

6

因为您将类型转换结果转换为整数,可能它有一个像 0.55 这样的小数部分,并且由于类型转换它已经删除了小数部分并且只给出了 0。尝试将 Payment 变量更改为 double,同时确保doubleloanamount不等于 0。

于 2013-01-22T12:04:31.230 回答
0

使 intRate 浮动 .... 如果 intRate 本身为 0 ,则计算付款 intRate * X 将给出 0 。您已经编写了 intRate = x * 11/100,如果小于 1,则为 0。

也使 mnthRate 浮动

于 2013-01-22T12:08:47.280 回答