Question: *****Help, not good at java programiing!! Q1. The program contructs and prints a Magic Square. Your program should implement and use the following method. /**
*****Help, not good at java programiing!!
Q1.
The program contructs and prints a Magic Square. Your program should implement and use the following method.
/** Constructs a magic square of size n.
Parameters:
n magic square size. n must be an odd integer.
Returns:
When n is odd returns a magic square.
When n is even returns null.
**/
private static int[] [] contructMagicSquare(int n)
Test your program with the following magic square sizes: 3, 5, 7, and 8.
Q2. Implement the method given in the problem. Also implement the following method:
/**
Makes a 2D array (matrix) where the [i][j] element contains the
* average of neighbors of [i][j] element in the input 2D array (values).
* for example:
* matrix[i][j] = neighborAverage(values, i, j ); *
* @param values 2D input array
* @return neighbor average matrix
*/
static double[][] makeNeighborAverageMatrix(int[][] values)
The main method should call makeNeighborAverageMatrix and print the returned 2D array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
