Thanks. Part of my problem looking at your solution is I wasn't sure how to print variables. Didn't realize the scheme format was very similar to the C format.
Thanks again. Part of the reason I had the tests set up like that was after I had it all set up I was going to implement bills.
ok, so, I got it working in regular scheme and it looks nice on the return, but... For whatever reason, on the amounts between 89 and 92 cents, it returns the wrong number of pennies. pretty much every other number comes out right. Why?
(define (change-iter change twenty ten five one quarter dime nickel penny)
(cond ((>= change 20.00)
(change-iter (- change 20.00) (+ twenty 1) 0 0 0 0 0 0 0))
((>= change 10.00)
(change-iter (- change 10.00) twenty (+ ten 1) 0 0 0 0 0 0))
((>= change 5.00)
(change-iter (- change 5.00) twenty ten (+ five 1) 0 0 0 0 0))
((>= change 1.00)
(change-iter (- change 1.00) twenty ten five (+ one 1) 0 0 0 0))
((>= change 0.25)
(change-iter (- change 0.25) twenty ten five one (+ quarter 1) 0 0 0))
((>= change 0.10)
(change-iter (- change 0.10) twenty ten five one quarter (+ dime 1) 0 0))
((>= change 0.050)
(change-iter (- change 0.050) twenty ten five one quarter dime (+ nickel 1) 0))
((> change 0.00)
(change-iter (- change 0.010) twenty ten five one quarter dime nickel (+ penny 1)))
(else
(newline)
(display (string twenty " Twenties"))
(newline)
(display (string ten " Tens"))
(newline)
(display (string five " Fives"))
(newline)
(display (string one " Ones"))
(newline)
(display (string quarter " Quarters"))
(newline)
(display (string dime " Dimes"))
(newline)
(display (string nickel " Nickels"))
(newline)
(display (string penny " Pennies")))))
This is a good lesson not to trust exact testing on floating point variables that undergo multiple calculations. You have to have tolerance. Change change units to mean a penny and you will have your exact answer.