[futurebasic] Re: [FB] Logic problem

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

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Thu, 16 May 2002 10:02:12 -0400
Even before I ask, Jay offers a more concise solution:

>  >I am building a small function to return the amount of change in U.S.
>>currency given a fractional dollar amount.
>>
>clear local mode
>local fn MakeChange$( price as double )
>dim as int cents,coins
>dim dStr$
>
>coins = price
>dStr = str$(coins)+" dollar(s) "  + CHR$(13)
>cents = (price - coins) *100
>
>coins = cents / 25
>dstr += str$(coins)+" quarter(s) "  + CHR$(13)
>cents -= coins * 25
>
>coins = cents / 10
>dstr += str$(coins)+" dime(s) "  + CHR$(13)
>cents -= coins * 10
>
>coins = cents / 5
>dstr += str$(coins)+" nickel(s) "  + CHR$(13)
>cents -= coins * 5
>
>dstr += str$(cents)+" cent(s) "  + CHR$(13)
>
>end fn = dStr
>
>dim as double i
>
>for i = 100 to 200 step 1
>print "$"; i*.01; " changes to:"
>print  fn MakeChange$( i*.01 )
>print
>next i
>
>  e-e
>  =J= a  y


Thanks Jay! You must have hit the e-mail send button a split second before me.

Ken