做个测试,希望有所帮助。代码% By lyqmath
function main()
clc
m = 8400;
taxes = ComputeTaxes(m)function taxes = ComputeTaxes(m)mm = m - 3500;
if mm <= 0
taxes = 0;
return;
end
if mm <= 1500
taxes = mm*3/100 - 0;
return;
end
if mm <= 4500
taxes = mm*10/100 - 105;
return;
end
if mm <= 9000
taxes = mm*20/100 - 555;
return;
end
if mm <= 35000
taxes = mm*25/100 - 1005;
return;
end
if mm <= 55000
taxes = mm*30/100 - 2755;
return;
end
if mm <= 80000
taxes = mm*35/100 - 5505;
return;
end
if mm > 80000
taxes = mm*45/100 - 13505;
return;
end
结果
taxes = 425>>
用if语句可以做
if a<3500
disp('不用纳税!');
elseif a<5000
……