// NAME: Liane Nakamura // STUDENT ID: 25806927 //CurrencyFormat.java // // ICS H22 Fall 2005 // Lab 2: The Price You Pay // // This class is provided as-is for use in your program. It formats // a currency amount (say, 355 cents) with a dollar sign, two digits // after the decimal point, etc., returning the result as a String. // // Examples: // // CurrencyFormat.format(1000) => "$10.00" // CurrencyFormat.format(50000000) => $500,000.00" // // This class also provides an example of the use of the String.format // method for formatting Strings. public class CurrencyFormat { public static String format(int cents) { return String.format("$%,d.%02d", (cents / 100), (cents % 100)); } }