📄 personal tax.cpp
字号:
#include<iostream.h>
void first(long double& x,char ch)
{if(ch=='y'||ch=='Y') x-=1260;
else x-=800;
if(x<=0) cout<<"\nYou don't need to pay any tax!\n";
}
long double tax(long double sal)
{long double n=0.0;int i,j;
long int a[]={0,500,2000,5000,20000,40000,60000,80000,100000};
double b[]={0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45};
for(j=0;;)
{if(sal>a[j]) j++;
if(j>=8) break;
if(sal<=a[j+1]) break;
}
for(i=j;i>0;i--) n+=(a[i]-a[i-1])*b[i-1];
n+=(sal-a[j])*b[j];
return n;
}
void main()
{long double sal;char ch;
do
{do
{cout<<"\nDo you work in Guangzhou?(y---yes/n---no)";
cin>>ch;
}while(ch!='y'&&ch!='Y'&&ch!='n'&&ch!='N');
do
{cout<<"\nIuput your salary please:";
cin>>sal;
}while(sal<0);
first(sal,ch);
if(sal>0)
{sal=tax(sal);
cout.setf(ios::fixed);cout.precision(2);
cout<<"\nYour tax is:"<<sal;
}
do
{cout<<"\nContinue?(y---yes/n---no)";
cin>>ch;
}while(ch!='y'&&ch!='Y'&&ch!='n'&&ch!='N');
}while(ch!='n'&&ch!='N');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -