题目:

     编写一个程序来计算税务部门征收所得税,计算税金的规定如下:

收入在5000元以下的,免税;

      收入在5000-10000元的,纳税4%

      收入超过10000元,纳税5%

程序要求用户在运行时通过文本框输入个人收入,alert()或document.write()输出应纳税金额。


代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>纳税金额</title>
    <script type="text/javascript">
        function outputTax(income)
        {
            var tax = 0;
            if(income>10000)
            {
                tax = 0.05*(income-10000)+0.04*5000;
            }
            else if(income>5000 && income<=10000)
            {
                tax = 0.04*(income-5000);
            }
            document.write("收入:"+income+"<br/>应纳税金额: "+tax);
        }
    </script>
</head>
<body>
    <form action="do.php" name="myform">
        <input type="text" name="income" required="required"/>
        <input type="button" value="输出" onclick="outputTax(myform.income.value)" />
    </form>
</body>
</html>

运行结果:

纳税

 

纳税

相关文章:

  • 2021-09-30
  • 2022-12-23
  • 2021-10-25
  • 2021-12-30
  • 2022-01-21
  • 2021-12-15
  • 2021-08-29
  • 2021-10-10
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-12-03
  • 2022-01-07
相关资源
相似解决方案