for (int r = 0; r < values.length; r++)
{

sum = sum + values [r];
sum = sum/values.length;

}


this is where your problem lies. if you need more help, post again and i'll elaborate