Guest User

tax thing (nub viewpoint)

a guest
Sep 23rd, 2011
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.     public double getTaxes(double salary)
  2.     {
  3.       double taxes = 0;
  4.       double taxable = 0;
  5.  
  6.       double[] taxBrackets = { 0, 5070, 8660, 14070, 21240, 40230, double.MaxValue };
  7.       double[] rates = { 0, .1, .14, .23, .3, .33, .45 };
  8.  
  9.       for (int i = 1; i < taxBrackets.Length; i++)
  10.       {
  11.         if (salary > taxBrackets[i - 1])
  12.         {
  13.           taxable = Math.Min(salary - taxBrackets[i - 1], taxBrackets[i] - taxBrackets[i - 1]);
  14.           taxes += taxable * rates[i];
  15.         }
  16.       }
  17.  
  18.       return taxes;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment