All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Just one expression (Posted on 2009-07-07) Difficulty: 2 of 5
Every individual with a monthly gross income that equals or exceeds certain limits is required to file a federal income tax return.

Suppose the progressive table form looks like this:
       gross income               % to be applied
    ----------------------------------------------
    =< 1,000.00                         0%
    > 1,000.00 and =< 1,500.00         10%
    > 1,500.00                         25%
    ----------------------------------------------
Thus:

* If the monthly gross income is US$800.00, the individual pays no tax;

* If it is US$1,200.00, he pays nothing over the first US$1,000.00 plus 10% of US$200.00 (US$1,200.00 - US$1,000.00), a total tax of US$20.00;

* If it is US$1,800.00, he pays nothing over the first US$1,000.00, plus 10% over US$500,00 (US$1,500.00 - US$1,000.00) plus 25% over US$300.00 (US$1,800.00 - US$1,500.00), a total tax of US$125.00.

Write a single math expression, function of those parameters, which gives the value of the tax to be paid.

  Submitted by pcbouhid    
Rating: 4.0000 (1 votes)
Solution: (Hide)
Knowing that there are many others expressions which can do the job, my solution (it looks more mnemonic) is as follows. The expression
            (A + B) + |A - B|
          (-------------------)
                    2 
where |A - B| is the absolute difference of A and B, returns the greater of A and B.

Calling this expression max(A, B) and being GI the gross income, the tax (T) to be payed can be evaluated by:
  T = ((max(GI, 1000) - 1000)) * 0.10 +
      ((max(GI, 1500) - 1500)) * (0.25 - 0.10)

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Possible solutionHarry2009-07-07 20:09:16
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (11)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information