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

Code for part 11 a is public static int intAverage( int arr[][]){ int sum=0; int

ID: 3867010 • Letter: C

Question

Code for part 11 a is

public static int intAverage(int arr[][]){

            int sum=0;

            int rows=arr.length;

            int column=arr[0].length;

            int count=0;

            for(int i=0;i<rows;i++){

                  for(int j=0;j<column;j++){

                        sum+=arr[i][j];

                        count++;

                        System.out.println(arr[i][i]);

                  }

                  System.out.println();

            }

            return sum/count;

      }

Dnt do this if u are not sure.Only attempt those who can give correct implementation of the method.Attach screenshot and code

COMP1022P Final Summer 2016-17 011. Arrays (Conts) (b) (9 points). Assume that you are given the method public int) neighbors ( int[] arr, introw, int col) which takes a square 2D integer array arr and two indices row and col as arguments, and returns a square 2-D integer array containing the values of the neighbors at location (, colof array arr. (that you don'to know the detailed row) the Note t need implementation of the method neighbors(O) and you can assume that the method works correctly at the corner and the edges of the array.) For example, given the 5x5 2-D array, A, the 3x3 2-D array B is returned when calling neighbors(A, 1, 1): 11 12 13 4148 162 A 1718 1924 41 1112 4 140 Complete the blur(O) method which takes a square 2-D integer array arr and returns a new 2-D array of the same size which contains at each position (row, col), the integer average of the values of the neighbors at location (row, col) of the array arr. You must use the method neighbors described above to obtain the values of the neighbors at location (row, col. The content in the original 2-D array arr should not be changed. Hints: You can use the intAverage() method defined in part (a) to compute the integer average. public int[) blur(int arr) 1 Page 7

Explanation / Answer

public int[][] blur(int[][] arr)

{

int rows=arr.length; // calculating rows

int cols=arr[0].length; // calculating columns

int[][] blurArray = new int[ rows ][ cols ]; // creating a new empty array of above row,col

for(int i = 0; i < rows; i++)

{

for(int j = 0; j < cols; j++)

{

int[][] neighbArray = neighbors(arr, i, j); // getthing the neighbor elements of each

// row and column position

blurArray[i][j] = intAverage(neighbArray); // calculating the average of each neighbor

}

}

return blurArray;

}

NOTE: Since you wanted only the method body hence I did it so. Please note that complete executable program is not possible to post until you provide the neighbors() method. However, as per the instruction provided with the question, the blur() method has been implemented exactly in line with it.

blur() Method

public int[][] blur(int[][] arr)

{

int rows=arr.length; // calculating rows

int cols=arr[0].length; // calculating columns

int[][] blurArray = new int[ rows ][ cols ]; // creating a new empty array of above row,col

for(int i = 0; i < rows; i++)

{

for(int j = 0; j < cols; j++)

{

int[][] neighbArray = neighbors(arr, i, j); // getthing the neighbor elements of each

// row and column position

blurArray[i][j] = intAverage(neighbArray); // calculating the average of each neighbor

}

}

return blurArray;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote