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;
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;
int PENNYV = 0;
int NICKELV = 0;
int DIMEV = 0;
int QUARTERV = 0;
int HALFV = 0;
for(int i = 0; i <= 100; i++){
PENNYV = (i * PENNY);
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 + PENNYV;
if(current == 100){
combinations++; // increment combination count
}
}
}
}
}
}
System.
out.
println("There are " + combinations
+ " possible combinations."); }
}