# Need Help

• 09-13-2002
Joes108
Need Help
I need help starting this program I have to Write a program that will determine the maximum number of combinations to make \$1 in change given six different coins. The coins you can use are pennies, nickels, dimes, quarters, fifty cent pieces, and the Susan B. Anthony dollar. For example, three possible combinations are:

Number of Coins Type
1 - Susan B. Anthony dollar
2 - 2 fifty cent pieces
3 - 2 quarters, 1 fifty cent piece

thanks for the help
• 09-13-2002
i used 6 nested loops and the line

if(((a * SBA) + (b * FCP) + (c * Q) + (d * D) + (e *N) + (f * P)) == 100)
then solution found

where
a - f represent the # of a given coin and are loop variables
SBA = 100;
FCP = 50;
Q = 25;
D = 10;
N = 5;
P = 1;
• 09-13-2002
geophyzzer
Try this, its not particularly efficient but it appears to work:

Code:

```#include <iostream> #include <cstdio> using namespace std; int main() {     int numCombos = 0;     cout << "Dollars HDollars Quarters Dimes Nickels Pennies" << endl;     cout << "------- -------- -------- ----- ------- -------" << endl;     for (int dollars = 0; dollars <= 1; dollars++) {       for (int halfdollars = 0; halfdollars <= 2; halfdollars++) {         for (int quarters = 0; quarters <=4; quarters++) {           for (int dimes = 0; dimes <= 10; dimes++) {             for (int nickels = 0; nickels <= 20; nickels++) {               for (int pennies = 0; pennies <= 100; pennies++) {                 if ((dollars*100 + halfdollars*50 + quarters*25 + dimes*10 + nickels*5 + pennies) == 100) {                   numCombos++;                   printf("%7d %8d %8d %5d %7d %7d\n", dollars, halfdollars, quarters, dimes, nickels, pennies);                 }               }             }           }         }       }     }     cout << endl << "Total Combos:  " << numCombos << endl; }```
• 09-13-2002
Joes108