Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public double GetTax(double income)
- {
- var rules = new[] {
- new { Taxable = 0, Rate = 0d },
- new { Taxable = 5070, Rate = 10d },
- new { Taxable = 8660, Rate = 14d },
- new { Taxable = 14070, Rate = 23d },
- new { Taxable = 21240, Rate = 30d },
- new { Taxable = 40230, Rate = 33d },
- new { Taxable = int.MaxValue, Rate = 45d }
- };
- var tax = 0d;
- for (var i = rules.Length - 1; i > 0; i--)
- {
- var taxable = income - rules[i - 1].Taxable;
- if (taxable > 0d)
- {
- tax += taxable * rules[i].Rate / 100d;
- income -= taxable;
- }
- }
- return tax;
- }
Advertisement
Add Comment
Please, Sign In to add comment