Hint: Look at this line
digitpercentage [p] = calculateLeadingDigit ((int) numbers [p])/numbers.length;
Your
p
value ranges from 0 to 9. But does
numbers
length varies same? You do
numbers[p]
, is not there a possibility of index out of range?
Debug step wise and see how the execution is happening and what are the values assigned.