一、本月有几天
#include <iostream>
using namespace std;
int main ()
{
int year,month;
cout<<"请输入年份:"<<endl;
cin>>year;
cout<<"请输入月份:"<<endl;
cin>>month;
if((year%4==0 && year%100!=0)||(year%400==0))
{
if(month==2)
cout<<"本月有29天";
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
cout<<"本月有31天";
if(month==4 || month==6 || month==9 || month==11)
cout<<"本月有30天";
}
else
{
if(month==2)
cout<<"本月有28天";
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
cout<<"本月有31天";
if(month==4 || month==6 || month==9 || month==11)
cout<<"本月有30天";
}
return 0;
}
二、定期存款利息计算器
#include<iostream>
using namespace std;
int main()
{
int type;
double money, period, rate, interest;
cout << "请输入存款金额:";
cin >> money;
cout << "存款期限" << endl;
cout << "1. 三个月 " << endl;
cout << "2. 六个月" << endl;
cout << "3. 一年 " << endl;
cout << "4. 二年" << endl;
cout << "5. 三年" << endl;
cout << "6. 五年" << endl;
cout << "请输入存款期限的代号:";
cin >> type;
if (type >= 1 && type <= 6)
{
switch (type)
{
case 1:
period = 0.25;
rate = 0.031;
break;
case 2:
period = 0.5;
rate = 0.033;
break;
case 3:
period = 1;
rate = 0.035;
break;
case 4:
period = 2;
rate = 0.044;
break;
case 5:
period = 3;
rate = 0.05;
break;
case 6:
period = 5;
rate = 0.055;
break;
}
interest = money * period * rate;
cout << "到期利息为:" << interest << "元,本息合计共" << interest + money << "元。" << endl;
}
else
cout << "选择存款类型错误!" << endl;
cout << "感谢您的使用,欢迎下次光临!" << endl;
return 0;
}
三、个人所得税计算器
#include <iostream>
using namespace std;
int main( )
{
double dSalary,dTax=0,dNetIncome=0;
cout<<"请输入您本月的收入总额(元):";
cin>>dSalary;
double Spare,TaxRate;
int deduction;
Spare=dSalary-3500;
if(Spare>0)
{
if(Spare<=1500) TaxRate=0.03,deduction=0;
else if(Spare<=4500) TaxRate=0.10,deduction=105;
else if(Spare<=9000) TaxRate=0.20,deduction=555;
else if(Spare<=35000) TaxRate=0.25,deduction=1005;
else if(Spare<=55000) TaxRate=0.30,deduction=2755;
else if(Spare<=80000) TaxRate=0.35,deduction=5505;
else TaxRate=0.45,deduction=13505;
}
else
{
TaxRate=0;
deduction=0;
}
dTax=Spare*TaxRate-deduction;
dNetIncome=dSalary-dTax;
cout<<"您本月应缴个人所得税 "<<dTax<<" 元,税后收入是 "<<dNetIncome<<" 元。\n";
cout<<"依法纳税,共享繁荣。谢谢使用!\n";
return 0;
}