View Single Post
Old 12-18-2008, 01:26 AM   #2 (permalink)
phpGuy
 
Newb Techie

Join Date: Dec 2008

Posts: 13

phpGuy is on a distinguished road

Default Re: Need Help with Program

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


Last edited by phpGuy; 12-18-2008 at 01:27 AM. Reason: indentation is off
phpGuy is offline