I have this application that I have written to calculate average. It comes up on the emulator but it wont calculate the average. I suspect its something with the string but i'm not positive. any ideas?
开发者_JS百科 import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import android.view.View.OnClickListener;
public class AvgActivity extends Activity {
/** Called when the activity is first created. */
Button bu1=null;
EditText et1=null;
EditText et2=null;
EditText et3=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bu1=(Button)findViewById(R.id.bu1);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
et3=(EditText)findViewById(R.id.et3);
bu1.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
}
}
});
double num;
public double mean(double[] m) {
double sum = 0;
for (int i = 0; i < double.length; i++)
{
sum += m[i];
}
return sum / double.length;
}
}
public double mean(double[] m) {
double sum = 0;
for (int i = 0; i < m.length; i++) {
sum += m[i];
}
return sum / m.length;
}
精彩评论