3-18 CurrencyFormat

Post date: Feb 1, 2014 2:45:18 PM

/*

This program demonstrates how to use the System.out.printf

method to format a number as currency.

*/

package currencyformat;

public class CurrencyFormat

{

    public static void main(String[] args) 

    {

            double monthlyPay = 5000.0;

            double annualPay = monthlyPay * 12;

            System.out.printf("Your annual pay is $%,.2f\n", annualPay);

    }  

}