Tax - gender and yearly income?
Show older comments
Hi, I am trying to calculate the income tax for a given person by status and yearly income, according to the table below for single and married persons. I have to use the switch and if commands but don't really know how to connect the two.
Single Person Married Person
chargeable income Rate Deduct chargeable income Rate Deduct
0-8500 0 0 0-11900 0 0
8501-14500 0.15 1275 11901-21200 0.15 1785
14501-19500 0.25 2725 21201-28700 0.25 3905
19501 and over 0.35 4675 28700 and over 0.35 6775
...this is what i've tried so far...thanks for the help!!!
function y=x
switch status
case 'single'
c = [0 1275 2725 4675];
if x=0:1:8500;
y=x
else
if x=8501:1:14500;
y=x-1275;
else
if x=14501:1:19500;
y=x-2725;
else
if x=19501:1:inf;
y=x-4675;
end
end
end
case 'married'
c = [0 1785 3905 6775]
otherwise
error('none')
end
Answers (1)
Walter Roberson
on 3 Apr 2013
Hint:
if 0 <= x & x <= 8500
y = x - c(1);
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!