复利计算

{
public static void main(String[] args){

double money = 1000; //本金

int years = 20; //存钱年数

double sum = 0; //存款总额

double r = 0.05; //利率

for(int i = 1 ; i<=years; i++){

sum = (1+ r) * i *money;

System.out.println("存入第"+i+"年后的存款总额为:"+sum);

}

}

}

posted @ 2016-03-12 18:15  26林发  阅读(130)  评论(1编辑  收藏  举报