1
#include <iostream>
using namespace std;
int main( )
{
double dSalary,dTax=0,dNetIncome=0;
cout<<"请输入您本月的收入总额(元):";
cin>>dSalary;
double x,TaxRate;
int deduction;
x=dSalary-3500;
if(x>0)
{
if(x<=1500) TaxRate=0.03,deduction=0;
else if(x<=4500) TaxRate=0.10,deduction=105;
else if(x<=9000) TaxRate=0.20,deduction=555;
else if(x<=35000) TaxRate=0.25,deduction=1005;
else if(x<=55000) TaxRate=0.30,deduction=2755;
else if(x<=80000) TaxRate=0.35,deduction=5505;
else TaxRate=0.45,deduction=13505;
}
else
{
TaxRate=0;
deduction=0;
}
dTax=x*TaxRate-deduction;
dNetIncome=dSalary-dTax;
cout<<"您本月应缴个人所得税 "<<dTax<<" 元,税后收入是 "<<dNetIncome<<" 元。\n";
cout<<"依法纳税,共享繁荣。谢谢使用!\n";
return 0;
}
3
#include<iostream>
using namespace std;
int main()
{
cout<<"欢迎使用利息计算器!"<<endl;
cout<<"请输入存款金额:\0"<<" ";
int money,number;
double interest,rate,term,sum;
//interest:利息;sum:金额;rate:利率;term:存期
cin>>money;
cout<<"=======存款期限======="<<endl;
cout<<"1. 3个月\n2. 6个月\n3. 一年\n4. 两年\n5. 三年\n6. 五年"<<endl;
cout<<"请输入存款期限的代号:";
cin>>number;
switch(number)
{
case 1: term=0.25;rate=0.031;break;
case 2: term=0.50;rate=0.033;break;
case 3: term=1.00;rate=0.035;break;
case 4: term=2.00;rate=0.044;break;
case 5: term=3.00;rate=0.050;break;
case 6: term=5.00;rate=0.055;break;
default : cout<<"对不起,无此选项"<<endl;
}
interest=money*term*rate;
sum=money+interest;
cout<<"到期利息为:"<<interest<<","<<"本息合计共:"<<sum<<"元"<<endl;
cout<<"感谢您的使用,欢迎下次光临!"<<endl;
return 0;
}
4
#include <iostream>
#include<cmath>
using namespace std;
int main( )
{
double x,y;
cout<<"输入x"<<endl;
cin>>x;
if (x<2) y=x;
else if (x<6) y=x*x+1;
else if (x<10) y=sqrt(x+1);
else y=1/(x+1);
cout<<"多分数段函数值为:"<<y<<endl;
}