Thanks all for the help. I got the program working a few days ago.
Code:
/**
* This program takes a user input of money in cents and prints all the possible
* representations of that amount as a combination of quarters, deimes, nickels,
* and pennies. It then displays the total number of possible configurations.
*
*/
import java.util.Scanner;
public class MakeChange
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println ("How many cents? ");
int cents = input.nextInt(); // User input of cents
int counter = 0; // declares the variable counter which keeps track of total configurations
for(int quarters = 0; quarters <= cents / 25; quarters++) // finds number of quarters
{
int centsAfterQuarters = cents - (quarters * 25);
for(int dimes = 0; dimes <= centsAfterQuarters / 10; dimes++) // finds number of dimes
{
int centsAfterDimes = centsAfterQuarters - (dimes * 10);
for(int nickels = 0; nickels <= centsAfterDimes / 5; nickels ++) // finds number of nickels
{
int centsAfterNickels = centsAfterDimes - (nickels * 5); // remaining cents are the pennies
counter++; //increments number of configurations after each iteration by 1
System.out.println(cents + " cents = " + quarters + " quarters + " + dimes + " dimes + " + nickels + " nickels + " + centsAfterNickels + " pennies");
}
}
}
System.out.println("There are " + counter + " possible ways to make " + cents + " cents using coins.");
}
}