|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectCorrectChange
public class CorrectChange
CS230 Homework 1
| Constructor Summary | |
|---|---|
CorrectChange()
|
|
| Method Summary | |
|---|---|
static void |
main(String[] args)
|
static int |
makeChangeWithOneDenomination(int total,
String denominationName,
int denomination)
Computes how many occurrences of the specified denomination ("denomination") should be used when making change for the specified amount of cents ("total"). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CorrectChange()
| Method Detail |
|---|
public static int makeChangeWithOneDenomination(int total,
String denominationName,
int denomination)
For example:
makeChangeWithOneDenomination(57, "quarters", 25) would print out "2 quarters" and return 7
since two quarters should be used when making change for 57 cents and since 7 cents will remain
after using the two quarters
makeChangeWithOneDenomination(14, "dimes", 10) would print out "1 dimes" and return 4
since one dime should be used when making change for 14 cents and since 4 cents will remain
after using the one dime
makeChangeWithOneDenomination(1743, "$5 bills", 500) would print out "3 $5 bills" and return 243
since 3 $5 bills should be used when making change for 1743 cents and since 243 cents will remain
after using the 3 $5 bills
makeChangeWithOneDenomination(1743, "$20 bills", 2000) would print out nothing and return 1743
since no $20 bills should be used when making change for 1743 cents and since 1743 cents will remain
after using no $20 bills
total - represents the amount of money in cents that we want to make change fordenominationName - represents the name of the bill or coins, e.g., "$5 bills"denomination - represents the amount of cents in a particular bill or coin, e.g., 500 (for $5 bills)
public static void main(String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||