I have ~400 statements using RoundingMode.HALF_UP
, and by the nature of the app, I'd like for the user to be able to choose between the rounding modes. However, I'm at a loss as to how to represent that as a variable, if possible. Because of the incredible amount of statements, I'd like to avoid if
statements.
Is it possible to do what I'm asking?
I've tried an enum, but that's all I could conjure. Everything else got about half a line through. Google hasn't helped. Any suggestions are welcome.
try this
RoundingMode roundingMode = ...;
...
BigDecimal bd3 = bd1.divide(bd2, 2, roundingMode);