Answer:
I will code in JAVA.
Preconditions:
- The float array of data are declared and initialized.
public float sumArray(float[] data) {
float sum = 0;
for(int i = 0; i < data.length; i++) {
sum = sum + data[i];
}
return sum;
}
Step-by-step explanation:
First, you have to declare a variable sum of type float and initialize with 0. In addition, this method has a for-loop to go through whole array of data and each element is added to the float value to sum. When the for loop ends, the sum variable is returned.