import java.text.DecimalFormat;
import java.text.Format;
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.JOptionPane;
/*
 * FormatExample.java
 *
 * Created on January 6, 2005, 7:17 PM
 */

/**
 *
 * @author Bill Kraynek
 */
public class FormatExample {
    
   /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int x = 3737373;
        double y = .07737737;
        double z = x*y;
        // a double must be cast to an int before assigning to an int
        int w = (int)z;
        JOptionPane.showMessageDialog(null,"No Format\nx = " + x + "\n y =  " + y + "\n z =  " + z + "\n w = " + w);
        Format fmt = NumberFormat.getInstance();
        JOptionPane.showMessageDialog(null,"Standard Format\nx = " + fmt.format(x) + "\n y =  " +fmt.format(y)
        + "\n z =  " + fmt.format(z) + "\n w = " + fmt.format(w));
        Format moneyFmt = NumberFormat.getCurrencyInstance();
        //Format moneyFmt = NumberFormat.getCurrencyInstance(Locale.FRANCE);
        JOptionPane.showMessageDialog(null,"Currency Format\nx = " + moneyFmt.format(x) + "\n y =  " +moneyFmt.format(y)
        + "\n z =  " + moneyFmt.format(z) + "\n w = " + moneyFmt.format(w));
        Format decFmt = new DecimalFormat("#.#####");
        JOptionPane.showMessageDialog(null,"Created Format #.#####\nx = " + decFmt.format(x) + "\n y =  " +decFmt.format(y)
        + "\n z =  " + decFmt.format(z) + "\n w = " + decFmt.format(w));
        decFmt = new DecimalFormat("#,###.##");
        JOptionPane.showMessageDialog(null,"Created Format #,###.##\nx = " + decFmt.format(x) + "\n y =  " +decFmt.format(y)
        + "\n z =  " + decFmt.format(z) + "\n w = " + decFmt.format(w));
     }
    
}

