The IRS used the following tax table Using if else if state
Solution
% comments
income=[5000,10000,15000,22000,30000,38000,50000];
for i=1:1:7 % as only seven income are given so loop from 1 to 7
if(income(i)<=10000)
tax=((10/100)*income(i));
fprintf(\'the tax due on $%d is::%d\',income[i],tax);
end
if(income(i)>10000&&income(i)<=20000)
tax=(1000+((20/100)*(income[i]-10000)));
fprintf(\'the tax due on $%d is::%d\',income[i],tax);
end
if(income(i)>20000&&income(i)<=40000)
tax=(3000+((50/100)*(income[i]-40000)));
fprintf(\'the tax due on $%d is::%d\',income[i],tax);
end
if(income(i)>40000)
tax=(9000+((20/100)*(income[i]-10000)));
fprintf(\'the tax due on $%d is::%d\',income[i],tax);
end
end % for loop ends
