public class DecimalFormatter
{
public static void main(String[] args)
{
/*--------------------------------------------------------
Define an integer and initialize to 500.
--------------------------------------------------------*/
int a = 500;
/*--------------------------------------------------------
Define an integer and initialize to 3.
--------------------------------------------------------*/
int b = 3;
/*--------------------------------------------------------
Define a double named answer as the
division of the two integers.
--------------------------------------------------------*/
double answer = a/b;
/*--------------------------------------------------------
Define an anonymous DecimalFormat object
and run the DecimalFormat class constructor
method passing the format code "0.00#" as the argument
and simultaneously calling the format method and
passing the double variable answer.
Then display the formatted number.
--------------------------------------------------------*/
System.out.println("The total payment will be: $" + new DecimalFormat("0.00#").format(answer));
}