// Test the DecimalFormat class. import java.text.DecimalFormat; public class TestDecimalFormat { public static void main(String[ ] argv) { DecimalFormat formatter = new DecimalFormat("#,##0.00"); double x = 34855.458937543; String formattedX; // Format the double x. formattedX = formatter.format(x); // Print the formatted value. System.out.println("$" + formattedX); } } // Output: $34,855.46