There is a good question on rounding decimals in Java here. But I was wondering how can I include the trailing zeros to display prices in my program like: $1.50, $1.00
T
I would recommend that you do this:
NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance();
double price = 2.50000000000003;
System.out.println(currencyFormatter.format(price));
This has the virtue of be locale-specific as well. This will work, for example, if you're in the euro zone instead of the US.