Check printer - Convert to English text from the input value.

Check printer function (or subroutine) - Convert to English text from the input value. 12.34 -> "twelve dollars and thirty four cents". For the range .01 to 9999.99 assuming valid input.

• can we assume that answers could be in codegolf way? – YOU Mar 7 '11 at 6:58
• Is this a function or a whole program? – gnibbler Mar 7 '11 at 12:11
• Hm... I did this once for MMIX... Wait some time and I change it to satisfy the conditions. That's fun! – FUZxxl Mar 7 '11 at 13:58
• How should 12.00 be written? "twelve dollars" or "twelve dollars and xx/00" or something? – Joey Adams Mar 8 '11 at 1:02
• You are generally expected to tag questions with a type-of-puzzle tag (so far code-golf or code-challenge). Please correct my edit if I chose poorly. – dmckee --- ex-moderator kitten Mar 11 '11 at 19:35

Common Lisp, 95

Newline not counted in:

(lambda(n &aux(d(floor n))(c(round(*(- n d)100))))
(format()"~R dollar~P and ~R cent~P"d d c c))


Sample use (assigning it to f):

CL-USER> (f .01)
"zero dollars and one cent"
CL-USER> (f 12.34)
"twelve dollars and thirty-four cents"
CL-USER> (f 9999.99)
"nine thousand nine hundred ninety-nine dollars and ninety-nine cents"