Question: public class TemperaturesRiskGrant { public static void main(String[] args) { int[] temps = {91,95,96,97,90,87,85,79,89,87,87,82,88,89,83,81,79,82,83,77,74,78,81,82,81,80,76,82,81,81}; //creates the array object int highValue = high(temps); int lowValue =

public class TemperaturesRiskGrant { public static void main(String[] args) { int[] temps = {91,95,96,97,90,87,85,79,89,87,87,82,88,89,83,81,79,82,83,77,74,78,81,82,81,80,76,82,81,81}; //creates the array object int highValue = high(temps); int lowValue = low(temps); int avgValue = avg(temps); System.out.println("The maximum value in the array is: " + highValue); System.out.println("The minimum value in the array is: " + lowValue); System.out.println("The average value in the array is: " + avgValue); } public static int high(int [] array) { int maximumValue = array[0]; for (int counter = 1; counter <= array.length; counter++) { if (array[counter] >= maximumValue) { maximumValue = array[counter]; } } return maximumValue; } public static int low(int [] array) { int minimumValue = array[0]; for (int counter = 1; counter <= array.length; counter++) { if (array[counter] < minimumValue) { minimumValue = array[counter]; } } return minimumValue; } public static int avg(int [] array) { int average = 0; for (int counter = 1; counter <= array.length; counter++) { average = average + array[counter]; } average = average / array.length; return average; } }

^^^^^^^^^^^^^^^this is giving me "Index 30 out of bounds for length 30"^^^^^^^^^^^^^^^^^^^^^^^^^

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!