The IRS used the following tax table Using if else if state


The IRS used the following tax table, Using if - else if statements determine the tax due for the income amounts in a variable-sized array named income. Use the income array shown below to test your code. Income - [5000, 10000, 15000, 22000, 30000, 38000, 50000] Output should look like the following: The tax due on $5000 is: $500.00 The tax due on $10000 is: $1000.00 The tax due on $15000 is: $2000.00 The tax due on $22000 is: $3600.00 The tax due on $30000 is: $6000.00

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

 The IRS used the following tax table, Using if - else if statements determine the tax due for the income amounts in a variable-sized array named income. Use th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site