-
-
Save NoelKennedy/1235276 to your computer and use it in GitHub Desktop.
the tax thingy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static decimal GetTaxes(decimal salary) | |
{ | |
var taxBands = new[] | |
{ | |
new Tuple<Decimal, Decimal, Decimal>(0, 5070, 0.1m), | |
new Tuple<Decimal, Decimal, Decimal>(5070, 8660, 0.14m), | |
new Tuple<Decimal, Decimal, Decimal>(8660, 14070, 0.23m), | |
new Tuple<Decimal, Decimal, Decimal>(14070, 21240, 0.3m), | |
new Tuple<Decimal, Decimal, Decimal>(21240, 40230, 0.33m), | |
new Tuple<Decimal, Decimal, Decimal>(40230, Decimal.MaxValue, 0.45m) | |
}; | |
return taxBands.Aggregate(0.0m, (taxOwed, taxband) => | |
{ | |
if (salary < taxband.Item1) | |
return taxOwed; | |
if (salary < taxband.Item2) | |
return taxOwed + ((salary - taxband.Item1) * taxband.Item3); | |
return taxOwed + ((taxband.Item2 - taxband.Item1) * taxband.Item3); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment