First of all, is there a reason why you use
Double objects instead of the primitive type
double? Also note that floating-point data types are not suitable for storing amounts of money in real-world programs because floating-point numbers have limited precision, you can get roundoff errors which are not acceptable when dealing with money.
There are several ways to print numbers with nice formatting. One way is to use
System.out.printf(). For example:
If you don't want to print it, but just return the result formatted in a
string, use
String.format("%.2f", number); instead (that returns a String).
Another, slightly more cumbersome way, is to use class java.text.NumberFormat.