Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Every year the US Internal Revenue Service (IRS) uses the Consumer Price Index t

ID: 3282447 • Letter: E

Question

Every year the US Internal Revenue Service (IRS) uses the Consumer Price Index to adjust the boundaries between taxation rates to prevent "bracket creep", a phenomenon in which tax rates would increase due to inflation without an increase in "real" income. For the year 2017 the "Tax Rate" and the "Taxable Income Bracket" are as shown in the table below Tax Rate 1096 15% 25% 28% 33% 35% 39.6% Taxable Income Bracket 0 to 9,325 to 37,950 to 91,900 to 191,650 to 16,700 to 418,400 to 9,325 37,950 91,900 191,650 416,700 418,400 unlimitted Craft a User-Defined Function (UDF) that accepts a value for Taxable Income as the first variable in the input argument list returns the tax rate associated with that amount of Taxable Income, expressed as a decimal number (e.g., 27% is 0.27) " If a negative value of Taxable Income is specified an easily understood error message should be displayed to the CW a Tax Rate of zero should be returned in the output argument. Note 1: No data should be "echoed" to the CW Note 2: You should notice that the value at the boundary between brackets appears in both the lower and higher Tax Rate Bracket. This is because the amount of tax owed for that amount is the same for either bracket. For this assignment, return the lower Tax Rate to identify the bracket.

Explanation / Answer

Here is the required MATLAB Code. Explanation is included in the comments -

function [ fin_rate ] = taxRate( income )

%taxRate - Returns the tax rate for given income

% If Income is a negative number return 0 and display error

if income < 0

fin_rate = 0;

disp('Taxable Income entered is invalid. Please enter a positive value.');

return;

end

% If Income is zero, then return 0

if income == 0

fin_rate = 0;

return;

end

% Store the boundaries and rates of tax brackets

boundaries = [0 9325 37950 91900 191650 416700 418400 Inf];

rates = [0.1 0.15 0.25 0.28 0.33 0.35 0.396];

% Assign a variable to keep track of Amount Left from Income

amount = income; % Initialize it with the income

% Create a variable to store the tax paid

tax_paid = 0;

% Index for current bracket

cur_bracket = 1;

% While amount being processed is more than the current bracket,

% tax still needs to be processed

while boundaries(cur_bracket) < amount

% Update the amount of tax to be paid for the current bracket

tax_paid = tax_paid + rates(cur_bracket) * (min(boundaries(cur_bracket + 1), income) - boundaries(cur_bracket));

% Update the tax bracket

cur_bracket = cur_bracket + 1;

end

% Get the rate, from the total income and the tax paid

fin_rate = tax_paid / income;

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote