c++ 计算银行存款的本息?谁能帮我编一下程序,谢谢了!

2024-11-23 08:52:17
推荐回答(2个)
回答1:

#include
#include
#include
using namespace std;

int main()
{
int year;
double money,rate,sum=0;
cout<<"Please enter money:";
cin>>money;
cout<<"\nPlease enter rate:";
cin>>rate;
cout<<"\nPlease enter year:";
cin>>year;
sum=money*(1+pow(money,1+rate));//计算sum
cout<<"\nThe Sum is:"<<
fixed< system("pause");
return 0;
}

回答2:

/*把你的计算本息和的公式用c语言分解了*/
#include"stdio.h"
main()
{
int money,year,i;
float rate,sum;
printf("input money and year:\n");
scanf("%d%d",&money,&year);
printf("input rate:\n");
scanf("%f",&rate);
sum=money;
for(i=0;i sum*=(1+rate);
printf("ben xi he :%f\n",sum);
}