Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static decimal GetTax(decimal amount)
- {
- var taxTable = new []
- {
- new {Lower=0m, Upper=5070m, Tax=0.10m},
- new {Lower=5070m, Upper=8660m, Tax=0.14m},
- new {Lower=8660m, Upper=14070m, Tax=0.23m},
- new {Lower=14070m, Upper=21240m, Tax=0.30m},
- new {Lower=21240m, Upper=40230m, Tax=0.33m},
- new {Lower=40230m, Upper=decimal.MaxValue, Tax=0.45m}
- };
- return taxTable
- .Where(t => amount > t.Lower)
- .Sum(t => t.Tax * (amount > t.Upper ? t.Upper - t.Lower : amount - t.Lower));
- }
Advertisement
Add Comment
Please, Sign In to add comment