我需要知道如何翻译这个:
进入一个看起来像这样的Java进程:
public static float computeAverage(float [] i){
//I have no idea what this is supposed to be.
}
或者甚至
public static double computeAverage(double [] i){
//Still have no idea what this is meant to be.
}
如果用双打更容易回答,那很好,但我真的不需要那种精确度。
*编辑:*好的,告诉我这是否正确:
public static float computeAverage(float [] i){
float tally = 0f;
for(int x=0;x<i.length;x++){
tally = tally + pValue(i[x]);
}
return tally / i.length;
}
public static float pValue(float i){
return 2 - 1f/i;
}