打卡1

问题描述:编写一个计算机个人所得税的程序,要求输入收入金额后,能够输出个人所得税,征收如下:

起始点为3500元,征收3%

1500~4500元,征收10%

4500~9000元,征收20%

9000~35000元,征收25%

35000~55000元,征收30%

55000~80000元,征收35%

超出80000元,征收45%

流程图:

 

 

伪代码:

start[6]={0,1500,4500,9000,35000,55000}

end[6]={1500,4500,9000,35000,55000,80000}

taxrate[6]={0.03,0.1,0.2,0.25,0.3,0.35}

input profit

tax=0

for i<-0 to 5

if(profit>start[i])

if(profit<=end[i])

tax+=(profit-start[i])*taxrate[i]

else

tax+=(end[i]-start[i])*taxrate[i]

else

break

if(profit>80000)

tax+=(profit-80000)*0.45

output tax

代码:

#include <iostream>

using namespace std;

int main()

{

int start[6]={0,1500,4500,9000,35000,55000};

int end[6]={1500,4500,9000,35000,55000,80000};

double taxrate[6]={0.03,0.1,0.2,0.25,0.3,0.35};

double profit,tax=0;

int i;

cin>>profit;

for(i=0;i<6;i++)

{

if(profit>=start[i])

{

if(profit<end[i])

tax+=(profit-start[i])*taxrate[i];

else

tax+=(end[i]-start[i])*taxrate[i];

}

else

break;

}

if(profit>80000)

tax+=(profit-80000)*0.45;

cout<<tax<<endl;

return 0;

 }

 

posted @ 2023-05-08 20:45  umiQa  阅读(11)  评论(0编辑  收藏  举报