Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having issues with this program. any help i have been able to find was usin

ID: 3678953 • Letter: I

Question

I am having issues with this program. any help i have been able to find was using files. We are not using files. I am having issues with the getData function as well as the average functions. I am able to get all the input info to show up but not using the getData function. I also can get the indexes as well. Please help as I know it is simple but for some reason I am stumped on it. Assignment is below. Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions: a. Function getData: This function reads and stores data in the two-dimensional array. b. Function averageHigh: This function calculates and returns the average high temperature for the year. c. Function averageLow: This function calculates and returns the average low temperature for the year. d. Function indexHighTemp: This function returns the index of the highest high temperature in the array. e. Function indexLowTemp: This function returns the index of the lowest low temperature in the array. (These functions must all have the appropriate parameters.)

Explanation / Answer

public static void main(String[] args)
{
System.out.println("The average high of the year is: " + averageHigh(getData()));
System.out.println("The average low of the year is: " + averageLow(getData()));
System.out.println("The highest temperature is: " + indexHighTemp(getData()));
System.out.println("The lowest temperature is: " + indexLowTemp(getData()));
}
public static int[][] getData()
{
int[][] data = {{40, 44, 53, 64, 74, 83, 87, 85, 78, 67, 56, 45},{26, 28, 34, 44, 54, 64, 69, 68, 60, 48, 39, 30}};
return data;
}
public static int averageHigh(int[][] data)
{
int total = 0;
int average = 0;
for (int i = 0; i < data[0].length; i++)
{
total += data[0][i];
average = total / data[0].length;
}
return average;
}
public static int averageLow(int[][] data)
{
int total = 0;
int average = 0;
for (int i = 0; i < data[1].length; i++)
{
total += data[1][i];
average = total / data[1].length;
}
return average;
}
public static int indexHighTemp(int[][] data)
{
int tempVal;
int maxIndex = 0;
for (int i = 0; i < data[0].length; i++)
{
tempVal = data[0][i];
if (tempVal > maxIndex)
{
maxIndex = data[0][i];
}
}
return maxIndex;
}
public static int indexLowTemp(int[][] data)
{
int tempVal;
int lowIndex = Integer.MAX_VALUE;
for (int i = 0; i < data[1].length; i++)
{
tempVal = data[1][i];
if (lowIndex > tempVal)
{
lowIndex = data[1][i];
}
}
return lowIndex;
}

}