I have a requirement where the input number is 30.5 and break up scale is 10. so the out put should be as 10+10+10+0.5
a) In line 28, I am trying to add the values in variable totalIncome. But it is not getting populated.
b) Each time while rounding the number, I am dividing it with 1 and setting the scale as 2. Is there any other way to do this.
c) Is there any other best way to write this program for the given requirement.
You really are making things difficult for yourself. Read the API documentation for BigDecimal and you find it mas methods for rounding, and constant ONE which you could use. You should never pass a fractional double to the BigDecimal constructor, because the imprecision in 888888.88 will be perpetuated and immortalised; you should use Strings eg "888888.88".