您的位置:首页 > 编程语言 > C语言/C++

C/C++ 银行存款N年本息和计算

2016-06-07 21:21 645 查看
/*
2015年11月29日15:35:22
银行存款本息和计算
*/
#include<math.h>
#include<stdio.h>
float count(float m,float r,float y)
{
if(y==1)
return m*(1+r);a
else
return count(m,r,y-1)*(1+r);
}

int main(void)
{
float money;      //原始存款金额
float money_rate; //存款利率
float year;         //存款年限
printf("Please enter the amount of money you want to deposit:");
scanf("%f",&money);

printf("Please enter the money rate of the bank: ");
scanf("%f",&money_rate);

printf("Please enter how long to deposit:");
scanf("%f",&year);
printf(  "%f",money*(  pow((1+money_rate),year)  )  );
printf("After %d years,you can get: ",(int)year);
printf("< %.2f > Yuan.\n",count(money,money_rate,year));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  存款本息和