[futurebasic] Re: [FB] Re: Logic problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2002 : Group Archive : Group : All Groups

From: Jay <jktr@...>
Date: Fri, 17 May 02 00:55:13 -0500
>Now I hope Alain and Jay will come along and shorten these to 10 
>lines at 100x speed!
>
Ken,

Well, here's the 10-line version, but the 100x speed will have to be up 
to Alain.

local fn MakeChange$( price as double )
dim dStr$,cents
dStr       = str$( fix(price)) + " dollar(s) "  + CHR$(13)
cents      = frac(price) * 100 + 0.1
dstr      += str$(cents \\ 25) + " quarter(s) " + CHR$(13)
cents      = cents mod 25
dstr      += str$(cents \\ 10) + " dime(s) "    + CHR$(13)
cents      = cents mod 10
dstr      += str$(cents \\ 5 ) + " nickel(s) "  + CHR$(13)
end fn = dStr + str$(cents mod 5) + " cent(s) "    + CHR$(13)

I confess I amazed myself on this one. I was in a great hurry this 
morning, but I saw your email and had my solution written, tested, and 
sent in less than 8 minutes. 

I pondered it during my travels, and came home to spend an hour 
experimenting, only to find I couldn't improve on my initial effort.  The 
10-line version is compact, but definitely slower than my first.

 e-e
 =J= a  y
  "