February 2014
Beginner
1248 pages
62h 25m
English
Lines 21–22 perform the interest calculation using BigDecimal methods multiply, add and pow. The expression in line 22 evaluates as follows:
1. First, the expression rate.add(BigDecimal.ONE) adds 1 to the rate to produce a BigDecimal containing 1.05—this is equivalent to 1.0 + rate in line 19 of Fig. 5.6. The BigDecimal constant ONE represents the value 1. Class BigDecimal also provides the commonly used constants ZERO (0) and TEN (10).
2. Next, BigDecimal method pow is called on the preceding result to raise 1.05 to the power year—this is equivalent to passing 1.0 + rate and year to method Math.pow in line 19 of Fig. 5.6.
3. Finally, we call BigDecimal method multiply on the principal object, ...
Read now
Unlock full access