Interest Calculations Using BigDecimal
Figure 8.16 reimplements the interest calculation example of Fig. 5.6 using objects of class BigDecimal
to perform the calculations. We also introduce class NumberFormat (package java.text) for formatting numeric values as locale-specific String
s—for example, in the U.S. locale, the value 1234.56, would be formatted as "1,234.56"
, whereas in many European locales it would be formatted as "1.234,56"
.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.