Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public double getTaxes(double salary)
- {
- double taxes = 0;
- double taxable = 0;
- double[] taxBrackets = { 0, 5070, 8660, 14070, 21240, 40230, double.MaxValue };
- double[] rates = { 0, .1, .14, .23, .3, .33, .45 };
- for (int i = 1; i < taxBrackets.Length; i++)
- {
- if (salary > taxBrackets[i - 1])
- {
- taxable = Math.Min(salary - taxBrackets[i - 1], taxBrackets[i] - taxBrackets[i - 1]);
- taxes += taxable * rates[i];
- }
- }
- return taxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment