Do exercise 5.4 on page 126 of the textbook. Submit an m-file named: tax_computa
ID: 3787321 • Letter: D
Question
Do exercise 5.4 on page 126 of the textbook.
Submit an m-file named: tax_computation_LastName.m.
5.4 The Receiver of Revenue (Internal Revenue Service) decides to change the tax table used in Section 5.5 slightly by introducing an extra tax bracket and changing the tax-rate in the third bracket, as follows:
Amend the logical vector script to handle this table, and test it on the following list of incomes (dollars): 5000, 10,000, 15,000, 22,000, 30,000, 38,000, and 50,000.
5.4 The Receiver of Revenue (Internal Revenue Service) decides to change the tax table used in Section 5.5 slightly by introducing anextra tax bracket and changing the tax-rate in the third bracket, as follows: Taxable income Tax payable 10% of taxable income $10,000 or less Between $10,000and $20,000 $1000+20% of amount by which taxable income exceeds $10,000 Between $20,000 and $40,000 $3000+30% of amount by which taxable income exceeds $20,000 More than $40,000 $9000+50% of amount by which taxable income exceeds $40,000 Amend the logical vector script to handle this table, and test it on the following list of incomes (dollars): 5000, 10,000, 15,000, 22,000, 30,000, 38,000, and 50,000.Explanation / Answer
% matlab code
% tax_computation_LastName.m
function tax = tax_computation(income)
tax = [];
for i=1:length(income)
if income(i) <= 10000
tax(i) = 0.1*income(i);
elseif income(i) <= 20000
tax(i) = 1000+ 0.2*(income(i)-10000);
elseif income(i) <= 40000
tax(i) = 3000+ 0.3*(income(i)-20000);
else
tax(i) = 9000+ 0.5*(income(i)-40000);
end
end
end
income = [5000 10000 15000 22000 30000 38000 50000];
tax = tax_computation(income);
disp(tax);
% output: 500 1000 2000 3600 6000 8400 14000
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.