Question: undefined In this last problem, you will implement a method to print a cell's neighbours on a 2D array. The method's header (documented with java

undefined In this last problem, you will implement a method to printa cell's neighbours on a 2D array. The method's header (documented withjava docs) is provided. The main method (do not alter it) willundefined

In this last problem, you will implement a method to print a cell's neighbours on a 2D array. The method's header (documented with java docs) is provided. The main method (do not alter it) will read N numbers to create the 2D array, and it will call your method for you. Be careful not to go out of the bounds of the 2D array! Example (see the output of a test case for the complete output) The method should print the neighbours of 11 in the following order: 6 7 8 10 12 14 15 16 L- 1 2 3 4 6 7 8 19 10 11 12 14 15 16 10 Problem 3.java New 1. import java.util.Arrays; 2 import java.util.Scanner; 3 4. public class Problem3 { 5 6 /** 7 * Method used to print all the neighbours of an element inside a 2D array. 8 * The method will print each neighbour in a new line as {row, col}: value 9 @param data the 2D array @param row the row coordinate of the centre (point we want to print the neighbours) 11 * @param col the col coordinate of the centre (point we want to print the neighbours) 12 13- public static void printNeighbours (int[][] data, int row, int col) { 14 15 } 16 17 - /** 18 * DO NOT ALTER ME! 19 * @param args NOPE! 20 21 - public static void main(String[] args) { 22 Scanner kb = new Scanner(System.in); 23 int[][] data = new int[kb.nextInt()][kb.nextInt()]; 24 25- for (int i = 0; i

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!