import java.util.*;
import java.lang.*;
/**
* To answer the question "How many combinations of coins add up to $1.00". US
* currency is assumed. Reptition is assumed. Does not calculate permutations
* where position is important.
**/
class Main
{
public static int PENNY = 1;
public static int NICKEL = 5;
public static int DIME = 10;
public static int QUARTER = 25;
public static int HALF = 50;
public static int PENNYV = 1;
public static int NICKELV = 5;
public static int DIMEV = 10;
public static int QUARTERV = 25;
public static int HALFV = 50;
private int combinations = 0;
{
Main main = new Main();
main.run();
}
private void run(){
// iterate through each coin and add up the combinations
// pennies
int current = 0;
for(int j = 0; j <= 20; j++){ // nickels
NICKELV = (j * NICKEL);
for(int k = 0; k <= 10; k++){ // dimes
DIMEV = (k * DIME);
for(int m = 0; m <= 4; m++){ // quarters
QUARTERV = (m * QUARTER);
for(int n = 0; n <= 2; n++){ // halves
HALFV = (n * HALF);
current = HALFV + QUARTERV + DIMEV + NICKELV;
if(current == 100){
combinations++; // increment combination count
}
}
}
}
}
System.
out.
println("There are " + combinations
+ " possible combinations."); }
}