package test
import java.math.BigDecimal
import static extension test.MyMath.*
class TaxRates2 {
/**
* Income is taxed on a formula of 5% from $0 up to $50,000,
* 10% from $50,000 to $100,000, and 15% over $100,000.
*
* @param income income to pay taxes from
* @return effective tax rate
*/
def static BigDecimal effectiveRate(BigDecimal income) {
var tax = 0.05bd * income
if (income > 50_000bd) {
tax = tax + 0.05bd * (income - 50_000bd)
}
if (income > 100_000bd) {
tax = tax + 0.05bd * (income - 100_000bd)
}
tax / income * 100bd
}
}