[quote] 原帖由 [i]杨志罡[/i] 于 2011-07-26 01:54 发表 [url=http://bbs.itheima.com/redirect.jsp?goto=findpost&pid=5250&ptid=576][img]http://bbs.itheima.com/images/common/back.gif[/img][/url]package com.heima.cast;
public class MoneyReturn{
public static void main(String[] args) {
MoneyReturn moneyReturn = new MoneyReturn();
System.out.println("楼主你会多还款"+(moneyReturn.counte(50000, 0.008, 6)-50000)+"还是一次付清吧");
}
public double counte(double price,double monthRate,int times){
double money = price;
for(int i= 0;i< times;i++ ){
money = money*monthRate+money;
}
return money;
}
}程序运行结果是:楼主你会多还款2448.515081843514还是一次付清吧 [/quote]
如果是2个月一还的话money = money*monthRate+money;这个就不对了吧,我想搂住的意思是俩个月一换,我想按实际情况也应该是2个月一还因为你得开支吧得按月开吧 |