Given an input of a 2D array of integers, input the integers and calculate the average of the top half and the bottom half of the array. The first line of the input will consist of two integers N and M, denoting the number of rows and columns of the array respectively. The next N lines will contain M integers separated by space. Your program should read these integers in, store them in a 2D array, and then calculate the average of the numbers stored in the first N / 2 rows, then calculate the average of the numbers stored in the last N / 2 rows. N will be even. Output both of these averages.

Please reply to this post with your solution.

public class Main { public static void main(String[] args) { int N = 100; boolean[] isPrime = new boolean[N + 1]; for (int i = 2; i <= N; i++) { isPrime[i] = true; } for (int i = 2; i*i <= N; i++) { if (isPrime[i]) { for (int j = i; i*j <= N; j++) { isPrime[i*j] = false; } } } // count primes int primes = 0; for (int i = 2; i <= N; i++) { if (isPrime[i]) primes++; } System.out.println( "The number of primes <= " + N + " is " + primes); } }

class Main { public static void main(String[] args) { int[][] arr = new int [3][2]; for(int i = 0; i < 3; i++){ for (int j = 0; j <2; j++){ arr[i][j] = i + j; } } for(int i = 0; i < 3; i++){ for (int j = 0; j <2; j++){ double total = 0; //Initialize accumulator double average; // Will hold the average for (int h = 0; h < arr.length; h++) { total += arr[i][j]; average = total / arr.length; System.out.println(average); } } } } }

I might not get into the zoom meeting. Because last time my zoom didn’t work.