c++第三次作业
2016-04-12 17:51
232 查看
一、本月有几天?
二、定期存款利息计算器
#include <iostream> using namespace std; int main() { int year,month; cout<<"输入年份和月份:"; cin>>year>>month; { if(month==2) { if(year%4==0||year%100==0) cout<<29; else cout<<28; } else if(month==1||3||5||7||8||10||12) cout<<31; else cout<<30; } return 0; }
二、定期存款利息计算器
#include <iostream> using namespace std; int main() { float l,j,n,c; char d; cout<<"欢迎使用利息计算器\n请输入存款金额"<<endl; cin>>j; cout<<"存款期限”<<endl<<1.三个月<<endl<<b.六个月<<endl<<3.一年<<endl<<4.两年<<endl<<5.三年<<endl<<6.五年<<endl<<请输入存款期限的代号:"; cin>>d; l=j*n*c; switch(d) { case 1:c==0.25,n==0.031;break; case 2:c==0.5,n==0.033;break; case 3:c==1,n==0.035;break; case 4:c==2,n==0.044;break; case 5:c==3,n==0.05;break; case 6:c==5,n==0.055;break; defalut:cout<<"发生错误"; } cout<<l; }三、多分数段函数求值
#include <iostream> #include <math.h> using namespace std; int main() { double x,y; cin>>x; if(x<2) y=x; else if(x>=2&&x<6) y=x*x+1; else if(x>=6&&x<10) y=sqrt(x+1); else y=1/(x+1); cout<<y; return 0; }
相关文章推荐