Programming Problem # 1 A country has the following tax structure: Annual Gross
ID: 3903362 • Letter: P
Question
Programming Problem # 1 A country has the following tax structure: Annual Gross Income (S) 0 15.000 15,001 30,000 30,001-50,000 50,001 -80,000 80,001- 120,000 Over 120,000 Tax None 18% for each dollar over 15.000 $2,500 + 23% for each dollar over 30,000 $7,560 + 28% for each dollar over 50.000 $15.950 + 32% for each dollar over 80,000 $29,050 + 38% for each dollar over l 20,000 | Write an M-file that when executed will request an annual gross income to be entered in dollars ($) and will display the tax owed on the command window. Demonstrate your program with the following 5 incomes and present the M-file and the command window containing all inputs and tax results. S17,068 $42,687 $68,903 $100,260 $254,661Explanation / Answer
calculateTax.m
function tax = calculateTax(income)
if income <= 15000
tax = 0;
elseif income <= 30000
tax = (income - 15000) * 0.18;
elseif income <= 50000
tax = 2500 + (income - 30000) * 0.23;
elseif income <= 80000
tax = 7560 + (income - 50000) * 0.28;
elseif income <= 1200000
tax = 15950 + (income - 30000) * 0.32;
else
tax = 29050 + (income - 1200000) * 0.38;
end
end
test.m
income = input('Enter the annual gross income: ');
calculateTax(income)?
**Comment for any further queries.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.