thanks hunter,
but yr suggestion doesn't work out.
But i got it solved.
Kramed from Daniweb:
The problem is you are doing integer division, which will truncate rather than round as you expect. In Java, 5/2 = 2 and 2/5 = 0 . To fix this problem, you need to make one of the operands in the division a floating point type (either float or double). Again, in Java, (float)5/2 = 2.5 and 2/(double)5 = 0.5 .