项目3:
#include<iostream>
#include<iomanip>
using namespace std;
int main( )
{
double money,y,z;
int x;
cout<<"欢迎使用利息计算器!\n" ;
cout<<"请输入存款金额:";
cin>>money;
cout<<"======存款期限======\n";
cout<<"1. 3个月\n";
cout<<"3. 6个月\n";
cout<<"3. 一年\n";
cout<<"4. 二年\n";
cout<<"5. 三年\n";
cout<<"6. 五年\n";
cout<<"请输入存款期限的代号:";
cin>>x;
switch(x)
{
case 1:y=money*0.031*0.25;break;
case 2:y=money*0.033*0.50;break;
case 3:y=money*0.035;break;
case 4:y=money*0.044*2;break;
case 5:y=money*0.050*3;break;
case 6:y=money*0.055*5;break;
default:;
}
z=money+y;
cout<<setiosflags(ios::fixed)<<setprecision(2)<<"到期利息为:"<<y<<"元,"<<"本息合计工共"<<z<<"元"<<endl;
cout<<"感谢您的使用,欢迎下次光临!"<<endl;
return 0;
}
项目2:
#include<iostream>
using namespace std;
int main()
{
int y,d,m,temp1=1,temp2=0;
cout<<"请输入年份:";
cin>>y;
if(y%400==0||(y%4==0&&y%100!=0))
temp2=1;
while(temp1)
{
cout<<"请输入月份:";
cin>>m;
if(!(m>0&&m<13))
{
cout<<"您输入的有错!"<<endl;
continue;
}
temp1=0;
}
if(m==2)
{
d=28;
if(temp2)
{
d++;
cout<<"本月有"<<d<<"天\n";
}
}
else if(m%2==0)
cout<<"本月共有30天;\n";
else
cout<<"本月共有31天;\n";
return 0;
}