Exact Change. Really going crazy trying to solve it

I am trying to solve it in a way i understand. Any help explaining how to go about it will be appreciated.

What have you tried so far? What has worked and what hasn’t? What part of your code is behaving differently than you expect it to?