Question: Add a method to the Table class below that computes the average of the neighbors of a table element in the eight directions shown in

Add a method to the Table class below that computes the average of the neighbors of a table element in the eight directions shown in Figure 15:

public double neighborAverage(int row, int column)

However, if the element is located at the boundary of the array, include only the neighbors that are in the table. For example, if row and column are both 0, there are only three neighbors.

public class Table

{

private int[][] values;

public Table(int rows, int columns) { values = new int[rows][columns]; }

public void set(int i, int j, int n) { values[i][j] = n; }

}

Figure 15

[65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76]

[65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] Sue Nina Susannah Larry Eve Sarah Adam Juliet Harry Katherine Tony

Step by Step Solution

3.37 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It seems there might be a misunderstanding with the image provided The description youve given is fo... View full answer

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 Java Programming Questions!