I have 5 arrayLists created that have double values
public ArrayList<Double> arrayList1 = new ArrayList<Double>();
public ArrayList<Double> arrayList2 = new ArrayList<Double>();
public ArrayList<Double> arrayList3 = new ArrayList<Double>();
public ArrayList<Double> arrayList4 = new ArrayList<Double>();
public ArrayList<Double> arrayList5 = new ArrayList<Double>();
I am trying to save them after the user enters values in an editText and clicks a submit button
if(spinnerPosition==1){
arrayList1.add(Double.parseDouble(enterText.getText().toString()));
}
Then I would like to load arrayList and use the values inside arrayList to calculate an average. I have the method to calculate the average, just need to know how to load arrayList to calculate average every time a new value is entered
public String arrayList1AverageResults(){
double sum=0.0;
if(arrayList1.size() > 0){
for ( int i=0; i < arrayList1.size() ; i++) {
sum += arrayList1.get(i);
}
arrayList1Avg = sum / arrayList1.size();
}
return arrayList1Avg;
}