here this is a general algorithm that should get you close
since it is an assignment I will not give you the actual code.
Quote:
//make sure this is integer division
intQuartCase = cents / 25
for each quarter case //starting with most quarters first
quarters = intQuartCase - quarter loop counter
//calculate how many cents are left using this number of quarters
qNewCents = cents - ( 25 * quarters )
//now repeat for dimes
intDimeCase = qNewCents / 10 for each dime case
dimes = intDimeCase - dime loop counter
dNewCents = qNewCents - (10 * dimes) //now repeat for nickels
//now pennies equals dNewCents - ( 5 * nickels ) because after calculating the nickels
// all that is left is the pennies
//before exiting the nickels for loop add one to a counter
//print quarters dimes nickels pennies //end nickels loop //end dimes loop //end quarters loop
//print number of possibilities using counter mentioned in nickels loop
|