Wefindthedifferential

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cket))/100.0; remainingIncome = brackets(currentBracket); end % move down to next bracket currentBracket = currentBracket - 1; end fprintf('Your tax on income of $%10.2f is $%10.2f\n', income, tax) 
 The
Matlab
style
might
be
best
seen
by
removing
the
;
and
looking
at
each
step.

We
find
the
differential
 tax
rates,
tax
all
income
at
lowest
rate,
then
tax
amount
above
the
first
cutoff
at
the
additional
rate
of
 the
next
bracket
and
so
on.

The
amount
in
each
range
is
found
by
subtracting
the
bracket
amount
from
 our
income.

You
might
see
that
this
means
for
$80,000,
there
would
be
a
couple
of
negative
amounts.

 A
logical
vector
is
introduced
here
that
checks
for
which
amounts
are
greater
than
0.

If
so,
the
vector
 value
is
1,
otherwise
0.

By
including
the
vector
in
the
final
tallying,
all
of
the
negative
values
disappear.

 function tax = computeTaxML(income) % Computes income tax for a graduated tax system using MAtlab % style program % Put brackets into brackets array in function starting with 0 % Put tax rates into taxrate array in function starting with lowest tax rate % Call function with income as input argument brac...
View Full Document

This document was uploaded on 03/16/2014 for the course CS 106 at Mt. Holyoke.

Ask a homework question - tutors are online