import java.math.BigInteger;
import java.text.NumberFormat;

import static java.math.BigInteger.ONE;

/**
 * Calculates sum of money obtained starting with a dollar on January 1 and doubling it 
 * each day until the end of February. The result is formatted as a dollar amount with 
 * commas to separate thousands.
 * 
 * @author Drue Coles
 */
public class NumberFormattingDemo {

    public static void main(String[] args) {
        
        // There are 59 days in January and February, so the sum is
        // 2^0 + 2^1 + 2^2 + ... + 2^58 = 2^59 - 1.
        BigInteger two = new BigInteger("2");
        BigInteger sum = two.pow(59).subtract(ONE);
               
        // get formatter for the default locale
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        System.out.println(nf.format(sum));
    }
}