Possible Duplicate:
USD Currency Formatting in Java
All- I have a small problem in which my app outputs an answer after inputs go through an equation and are rounded to two decimal places after the decimal point. My problem is that if the number comes out even like $12.80 the output looks like $12.8. I want it to look like $12.80. Not the biggest deal but I am in the final stages of development and would like to clean it up to look nice. Here is some of my code:
Float result2 = result / l3;
double data2 = result2;
int decimalPlaces2 = 2;
double roundBase2 = Math.pow(10, decimalPlaces2);
data2 = (double)(Math.round(data2 * roundBase2)) / roundBase2;
answer.setText("$" + Double.toString(data2));
Thanks for your time!
1 Answer