enter image description here

enter image description here

Can someone please help me, as far as I think this code should give back the number of coins needed but it is not working.

1 Answer 1


The problem is that the code uses do/while loops when it should have used while loops.

A do/while loop will ALWAYS run at least once. That means that it will add 4 coins and subtract at least 25 cents, 10 cents, 5 cents and 1 cent no matter what the amount is.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .