问题描述
征收税款时,税率与收入有关,若规定收入 1000 元以下税率为 3%,1000~2000 元(包括 1000 元)税率为 4%,2000~3000(包括 2000 元)元税率5%,3000 元及以上税率为 6%。要求:输入收入,求出税款及税后收入。
例如,输入 500,输出税款为 15,税后收入为 485;输入 3500,输出税款为 210,税后收入为 3290。
实现程序
代码如下(示例):
#include <iostream>
using namespace std;
int main()
{
double t,i,ATI; //定义税收为t,收入为i,税后收入为ATI
cout<<"Please enter income:";
cin>>i; //输入收入
if(i<1000)
{
t=i*0.03; //计算税收 :税收=收入*税率
ATI=i-t; //计算税后收入:税后收入=收入-税收
cout<<"Tax is:"<<t<<endl;
cout<<"After tax income is:"<<ATI<<endl;
}
else if(1000<=i&&i<2000)
{
t=i*0.04;
ATI=i-t;
cout<<"Tax is:"<<t<<endl;
cout<<"After tax income is:"<<ATI<<endl;
}
else if(2000<=i&&i<3000)
{
t=i*0.05;
ATI=i-t;
cout<<"Tax is:"<<t<<endl;
cout<<"After tax income is:"<<ATI<<endl;
}
else if(i>=3000)
{
t=i*0.06;
ATI=i-t;
cout<<"Tax is:"<<t<<endl;
cout<<"After tax income is:"<<ATI<<endl;
}
return 0;
}
实验结果
如下(示例):
Please enter income:500
Tax is:15
--------------------------------
Process exited after 6.435 seconds with return value 0
请按任意键继续. . .
Please enter income:3500
Tax is:210
--------------------------------
Process exited after 6.435 seconds with return value 0
请按任意键继续. . .