个人所得税

<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta charset="utf-8">
</head>

<body>
<script>

/**
* 个税计算
*/
function calPersonalTax(){
var salary = parseInt(prompt("请输入您本月的工资:",0.0));
var _salary = salary;//保存原始工资

var tax = 0; //最终缴纳的税金

//1、判断 salary 是否 > 9000 , 如果大于9000的话,9000以上部分 缴纳 20% 的税,9000以及下部分,按下个梯度算
if(salary > 9000){
//计算 大于 9000部分的税金
tax = tax + (salary - 9000) * 0.2;
salary = 9000;
}
//2、判断 salary 除9000以外的部分是否大于5000,如果大于的话 缴纳 10% 的税
if(salary > 5000){
tax = tax + (salary - 5000) * 0.1;
salary = 5000;
}
//3、判断 salary 是否大于 3500
if(salary > 3500){
tax = tax + (salary - 3500) * 0.03;
}

console.log("您的工资为:"+_salary + "元,您共需要缴纳的税金为:"+tax+"元,实发工资:"+(_salary - tax)+"元");
}

/**
* 计算 克莱托指数
*/
function calKlt(){
var height = parseFloat(prompt("请输入身高(m)",0.0));
var weight = parseFloat(prompt("请输入体重(kg)",0.0));

var klt = weight / (height * height);

console.log("您的克莱托指数为:"+klt);
if(klt < 20){
console.log("偏瘦");
}else if(klt > 25){
console.log("偏胖");
}else{
console.log("恭喜你,正常 !");
}
}


</script>
<button onclick="calKlt()">计算克莱托</button>
<button onclick="calPersonalTax()">个税计算器</button>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/lijun6/p/10449631.html