>>>Thanks for your reply... Actually I'll make it more clear,
>>>
>>>We've around 400 labours in our company & I'm making a Payroll program, For eg. one labour's salary is say 356 Dirhams (Currency Used in UAE), so the program should return this :-
>>>
>>>100x3=300
>>>50x1=50
>>>5x1=5
>>>1x1=1 Total is 356
>>>
>>>Same way the loop will scan all the 400 records and update a dbf or cursor for all the employees.
>>>
>>>Finally I can take the total report and give it to bank (as we are paying salary by cash ), so they can arrange the amount accordingly...
>>>
>>>Can you pls tell me if there is already a program made for this thing...
This should do the trick:
PARAMETERS tiAmount
LOCAL laDenominations, liCount, liRest, i
DIMENSION laDenominations[4]
laDenominations[1] = 100
laDenominations[2] = 50
laDenominations[3] = 5
laDenominations[4] = 1
liRest = tiAmount
FOR i = 1 TO ALEN(laDenominations, 1)
liCount = INT(liRest/laDenominations[i])
liRest = MOD(liRest, laDenominations[i])
IF liCount > 0
? laDenominations[i], liCount, liCount * laDenominations[i]
* Or insert into cursor
* INSERT INTO Denominations (Denomination, Count) ;
VALUES laDenominations[i], liCount
ENDIF
ENDFOR
Arne
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only