/* Author : Michael Robinson Program : decimalFormatClass.java Purpose : How to print numbers with decimal formats Updated : Jan 29, 2099 */ import java.text.DecimalFormat; import java.util.Scanner; public class decimalFormatClass { public static void process() { int x = 0; double amount = 1000; //creates the moneyFormat object used to describe how numbers //are to be displayed DecimalFormat moneyFormat = new DecimalFormat("$ #,###.000"); for( x = 10; x < 15; x++ ) { amount = amount + ( .005 * x ); System.out.println( "\nOriginal : " + amount ); //using moneyFormat.format to display numbers System.out.println( "Formatted: US " + moneyFormat.format( amount ) ); }//end for loop }//end public static void process() public static void main( String arg[] ) { process(); }//end public static void main( String arg[] ) }//end class decimalFormatClass