Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- decimal GetTaxes(decimal salary)
- {
- var rates = new[]
- {
- new { Threshold = 40230.0m, Rate = 0.45m },
- new { Threshold = 21240.0m, Rate = 0.33m },
- new { Threshold = 14070.0m, Rate = 0.3m },
- new { Threshold = 8660.0m, Rate = 0.23m },
- new { Threshold = 5070.0m, Rate = 0.14m },
- new { Threshold = 0.0m, Rate = 0.1m },
- };
- decimal tax = 0;
- foreach (var r in rates)
- {
- decimal slice = salary - r.Threshold;
- if (slice <= 0)
- continue;
- tax += r.Rate * slice;
- salary -= slice;
- }
- return tax;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement