Question: I need to print a Java 2D array with input from user and then from that array, calculate the number of rings of the array.

I need to print a Java 2D array with input from user and then from that array, calculate the number of rings of the array. The pic shows an example of what the program should look like.I need to print a Java 2D array with input from user

I'm having trouble calculating the number of 'rings' in the array and also listing the outer ring elements going clockwise. If anyone could help me write methods to calculate the outer ring elements.

The main issue for me is when the array that is inputted is not an n x n array but and m x n meaning there is a different number of rows and columns. I know that every odd number of rows and a matching number of columns or greater will equal a new ring. (Ex. 1 row 2 column = 1 ring, 3 row 4 column = 2 ring, 5 row 6 column = 3 ring, etc..). I am just confused on how to put this into code and also calculating the outer ring starting from the top right corner and then going clock wise.

Enter an integer between 5 and 10 inclusive for number of Columns: 7 Enter an integer between 5 and 10 inclusive for number of Rows: 5 Generating random int array with 7 columns and 5 rows 721 524_494712 636 911221 5$9 447 748 252 235 969 314 308 732 150 746 662 562 285 9$4 418 259 785 331 860 293 802 390196 807 229 619 770 The number of rings in the array = 3 Sum of all array elements = 18901 Average of all array elements = 540.62856 Number of elements in outer ring = 20 Outer ring elements listed going clockwise: 221 314 285 293 770 619 229 807 196 390 802 954 308 559 721 524 494 712 636 911 Sum of outer ring elements = 10745 Average of outer ring elements = 537.25

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!