Class Name: ThreeCentCoin
Method Name: getChange
Parameters: int
Returns: int
Imagine a new 3-cent coin were introduced to our economy, revolutionizing how
change was given back to a customer. Create a class called ThreeCentCoin that
includes the method getChange(int) that takes an amount of change (cents) and
returns the minimum number of coins required to make it, using ONLY quarters,
dimes, nickels, the 3-cent coin, and pennies only. Here is the method signature:
public int getChange(int amount);
amount is a positive integer less than 1000.
Examples:
*If amount=9, change can best be given with three 3-cent coins (or a nickel,
penny, and 3-cent coin), and the method returns 3.
*If amount=10, change can be given with a dime, and the method should return 1.
*If amount=100, the method returns 4.
*If amount=898, the method returns 38 (35 quarters, 2 dimes, and 1 3-cent coin).
|