import java.util.Arrays;
public class TestScores {
public static float getAverage(float arr[]){
float total = 0;
for (float x : arr){
if (x < 0 || x > 100){
throw new IllegalArgumentException();
}
else{
total += x;
}
}
return (total / arr.length);
}
public static void main(String [] args){
float arr[] = {1,100,0,43,-1};
System.out.println(getAverage(arr));
}
}
In the main method we test our getAverage method with the arr array. You can replace the values in the arr array and test your own values. I hope this helps!