php趣味编程-php求个人所得税
<?php
header("Content-Type: text/html; charset=utf-8");
/*
个人所得税 以3500后的数字
1 500 5 0
2 500-2000 10 25=500*0.5
3 2000-5000 15 25+150 = 175
4 5000-20000 20 25+150+450 = 625
5 20000-40000 25 25+150+450+15000*0.2=625+3000=3625
6 40000-60000 30 3625 + (40000-20000)*0.25 =3625 +5000=8625
7 60000-80000 35 8625+6000 = 14625
8 80000-100000 40 14625 + 2*0.35 = 21625
9 100000-..... 45 21625 + 2*0.4 = 29625
4000 - 3500 = 500*0.05=25
4100 -3500 = 610 = 500*0.05+110*0.10=25+11
8000 -3500 = 4500 = 500*0.05 + (2000-500)*0.1 + 2500*0.15
*/
?>
<?php
$money = 1108800; //个人的月收入
$jibie = $money - 3500;//交税的钱
if($jibie <= 500)
{
$a = $jibie * 0.05;//所得税-就是每个月交的税
}
else if($jibie <= 2000){
$a = 25 +($jibie - 500)*0.1;
}
else if($jibie <= 5000){
$a = 175 + ($jibie - 2000)*0.15;
}
else if($jibie <=20000){
$a = 625 + ($jibie - 5000)*0.2;
}
else if($jibie <= 40000){
$a = 3625+($jibie - 20000)*0.25;
}
else if($jibie <=60000){
$a = 8625 + ($jibie - 40000)*0.3;
}
else if($jibie <=80000){
$a = 14625 + ($jibie - 60000)*0.35;
}
else if($jibie <=100000){
$a = 21625 +($jibie - 80000)*0.4;
}
else{
$a = 29625+($jibie - 100000)*0.45;
}
//echo $a;
?>
<?php
/*
累积的不要手动算
*/
$salary = array(0,500,2000,5000,20000,40000,60000,80000,100000);//用来存个人所得的钱
$rate =array(5,10,15,20,25,30,35,40,45);//税息
$moneys = 5000;//假设月收入
$b = $moneys - 3500;
$index = 0;
$sum = 0;
for($i=0;$i<sizeof($salary);$i++){
if($b <$salary[$i]){
$index = $i;
break;
}
}
//循环得到扣除累计算
for($i=0;$i<$index;$i++)
{
$sum = $sum+( $salary[$i+1] - $salary[$i] )*$rate[$i]*0.01;
}
$a = $sum + ($moneys-$salary[$index-1])*$rate[$index-1]*0.01;
echo '月收入:'.$moneys.'交税是:'.$a;
?>