Question
Create an application named SquareMatrixCenter whose main method asks the user to enter an integer number n (between 2 and 10), and an n by
Create an application named SquareMatrixCenter whose main method asks the user to enter an integer number n (between 2 and 10), and an n by n integer matrix then passes the matrix with the values entered by the user to the following method:
static void printMatrixCenter(int [][] matrix): prints the square matrix at the center of the given matrix, that is all the numbers of the given matrix except those on the first and last row, and first and last column.
Use the Scanner class to read the users input.
Example 1.
Input:
Please enter an integer between 2 and 10: 4
Please enter a 4 by 4 matrix:
5 7 7 8
12 0 -5 15
3 12 9 10
7 3 8 7
Output:
The center of the matrix is :
0 -5
12 9
Example 2.
Input:
Please enter an integer between 2 and 10: 6
Please enter a 6 by 6 matrix:
5 7 7 8 6 8
12 0 -5 15 5 0
3 12 9 10 1 3
7 3 8 7 2 7
0 6 -7 8 1 12
1 1 2 6 9 10
Output:
The center of the matrix is :
0 -5 15 5
12 9 10 1
3 8 7 2
6 -7 8 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started