/*利息计算器*/
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
int m,d,c;
double rate,bj,lx;
cout<<"输入存款金额(元):"<<endl;
cin>>bj;
cout<<"输入存款类型:活期/定期"<<endl;
cout<<"1.活期 \n"<<"2.定期 \n";
cin>>c;
switch(c)
{
case 1:
{
cout<<"输入活期存款时间(日):";
cin>>d;
rate=0.0035;
lx=bj*rate/360*d;
cout<<"活期存款利息为"<<lx<<endl;
}
break;
case 2:
{
cout<<"输入定期存款时间(月):";
cin>>m;
switch(m)
{
case 3:
rate=0.026;
break;
case 6:
rate=0.028;
break;
case 12:
rate=0.03;
break;
case 24:
rate=0.044;
break;
case 36:
rate=0.05;
break;
case 60:
rate=0.55;
}
lx=bj*rate/12*m;
cout<<"利息为:"<<lx<<"元。"<<endl;
}
}
return 0;
}
练习,计算利息
最新推荐文章于 2024-03-01 22:45:40 发布