dimanche 3 mai 2015

Refactoring if statement in java

I need some help refactoring this if-statement. I thought of declaring the percerntage as constants. I also thought to make a method that includes the code inside the if brackets. What else can i do? Thank you for your time.

if(totalReceiptsAmount >= getIncome() && totalReceiptsAmount <  0.20 * getIncome())
        setTaxIncrease(getBasicTax() + 0.05 * getBasicTax());
    if(totalReceiptsAmount >=  0.20 * getIncome() && totalReceiptsAmount <  0.40 * getIncome())
        setTaxIncrease(getBasicTax() - 0.05 * getBasicTax());
    if(totalReceiptsAmount >=  0.40 * getIncome() && totalReceiptsAmount <  0.60 * getIncome())
        setTaxIncrease(getBasicTax() - 0.10 * getBasicTax());
    if(totalReceiptsAmount >=  0.60 * getIncome())
        setTaxIncrease(getBasicTax() - 0.15 * getBasicTax());

Aucun commentaire:

Enregistrer un commentaire