The main problem in your code is probably the duplication of code, meaning if you want to change e.g., the condition, you'd probably have to apply the same change in all four conditions. So you could try to factor out the common functionality, as you already suggested for the conditionals. So you could define a method
private boolean receiptsAmountIsBetweenFactorOfXAndYOfIncome(double x, double y){
return totalReceiptsAmount >= x * getIncome() && totalReceiptsAmount < y * getIncome();
}
and update your if-statements accordingly:
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0, 0.2))
setTaxIncrease(getBasicTax() + 0.05 * getBasicTax());
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.2, 0.4))
setTaxIncrease(getBasicTax() - 0.05 * getBasicTax());
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.4, 0.6))
setTaxIncrease(getBasicTax() - 0.10 * getBasicTax());
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.6, 1))
setTaxIncrease(getBasicTax() - 0.15 * getBasicTax());
Now, there's still duplication in the body of the if statements. So you could introduce an other method:
private void increaseTaxByFactorOfX(double x){
setTaxIncrease(getBasicTax() + x * getBasicTax());
}
and update the if-statements again:
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0, 0.2))
increaseTaxByFactorOfX(0.05);
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.2, 0.4))
increaseTaxByFactorOfX(-0.05);
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.4, 0.6))
increaseTaxByFactorOfX(-0.10);
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(0.6, 1))
increaseTaxByFactorOfX(-0.15);
Now, if you want, you can detect a pattern in the used numericals, or simply hardcode the numericals in an array or a list and use a loop instead of multiple similar if-statements:
double[] factorOfIncome = {0, 0.2, 0.4, 0.6, 1};
double[] taxIncreaseFactor = {0.05, -0.05, -0.10, -0.15};
for(int i = 0; i<taxIncreaseFactor.length; i++)
if(receiptsAmountIsBetweenFactorOfXAndYOfIncome(factorOfIncome[i], factorOfIncome[i+1]))
increaseTaxByFactorOfX(taxIncreaseFactor[i]);
This last refactoring step gets completely rid of the duplication, but in my opinion makes the code a bit less understandable.
Edit: Note that I assumed that the first conditional should be
if(totalReceiptsAmount >= 0 * getIncome() && //...
as it really looks like this is what you intended to write. If this isn't the case, then the first conditional would need to be treated separately.
else ifs to remove the double checks and factor out the function call, storing only the percentages inside the ifs.else ifwith onlyifif- how istotalReceiptsAmountgoing to be both greater thangetIncome()and less than0.2 * getIncome()? I'm assuming the income is not negative.