//NAME: Danish Khan //STUDENT ID: 47324012 //NAME: Adam Su //STUDENT ID: 23628358 // CurrencyFormat.java // // ICS H22 Winter 2006 // Lab 3: 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)); } }