Frac Function |
Namespace: XSharp.RT
1FUNCTION GiveChange(fMoney AS FLOAT) AS VOID PASCAL 2LOCAL fChange AS FLOAT 3? "Dollars: $", Integer(fMoney) 4fChange := Frac(fMoney) 5// While there is a cent left 6DO WHILE fChange >= 0.01 7 // Must check low amounts first: 8 DO CASE 9 CASE fChange < 0.05 10 ? "Pay a cent" 11 fChange -= 0.01 12 CASE fChange < 0.10 13 ? "Pay a nickel (5 cents)" 14 fChange -= 0.05 15 CASE fChange < 0.25 16 ? "Pay a dime (10 cents)" 17 fChange -= 0.10 18 CASE fChange < 0.5 19 ? "Pay a quarter (25 cents)" 20 fChange -= 0.25 21 OTHERWISE 22 ? "Pay half a dollar" 23 fChange -= 0.50 24 ENDCASE 25ENDDO