![]() |
[原创]计算个人工资所得税2
计算个人工资所得税是一个十分使用的程序,以前我已经用if语句实现过,那叫计算个人工资所得税1,今天使用switch语句实现,是又一种选择类型,数据分档选用缴税额除500的整数部分,要使用类型转换函数num2cell,取名为计算个人工资所得税2,可作为教学的一个范例。程序全文如下:
clear,x=input('输入全月应纳税工资'); switch fix(x/500) case 0 s=x*0.05; case num2cell(1:3) s=0.1*(x-500)+25; case num2cell(4:9) s=0.15*(x-2000)+175; case num2cell(10:39) s=0.2*(x-5000)+625; case num2cell(40:79) s=0.25*(x-20000)+3625; case num2cell(80:119) s=0.3*(x-40000)+8625; case num2cell(120:159) s=0.35*(x-60000)+14625; case num2cell(160:199) s=0.4*(x-80000)+21625; otherwise s=0.45*(x-100000)+29625; end fprintf('缴所得税:%8.2f\n',s) |
所有时间均为北京时间。现在的时间是 06:31。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.