Instruction: Create a java program that generates elements (randomly from 10 - 75) of a 2-dimensional array (5x5) using the Random Class then perform the following: 1) Output the array elements 2) Output the sum of prime numbers in the array 3) Output the elements in the main diagonal. 4) Output the sum of the elements below the diagonal. 5) Output the sum of the elements above the diagonal. 6) Output the odd numbers below the diagonal. 7) Output the even numbers above the diagonal. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items in bold italic are generated, calculated and printed by the program):
use two dimensional array and put comment on what each line of code does
![PART 2: TwO-DIMENSIONAL ÅRRAY
Instruction:
Create a java program that generates elements (randomly from 10 – 75) of a 2-dimensional array
(5x5) using the Random Class then perform the following:
1) Output the
2) Output the sum of prime numbers in the array
3) Output the elements in the main diagonal.
4) Output the sum of the elements below the diagonal.
5) Output the sum of the elements above the diagonal.
6) Output the odd numbers below the diagonal.
7) Output the even numbers above the diagonal.
array
elements
Sample Input/Output:
Depicted below are sample outputs when the program is executed (the items in bold
characters are input from the user, while the items in bold italic are generated,
calculated and printed by the program):](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9456d33b-7da7-418b-baa4-da360d928341%2Fb9853b65-51c9-46bf-ad21-85382b77d999%2Fqpmc94_processed.png&w=3840&q=75)
![1) Output the array elements
33
21
30
45
32
50
10
50
35
42
25
12
35
12
11
45
14
50
28
21
15
41
15
19
41
2) Output the sum of prime numbers in the array.
112
3) Output the elements in the main diagonal.
21 10 35 28 41
4) Output the sum of the elements below the diagonal.
286
5) Output the sum of the elements above the diagonal.
311
6) Output the odd numbers below the diagonal.
25 45 15 41 19
7) Output the even numbers above the diagonal.
30 32 50 42 12
Required: The java file (FamilyName_2Dim.java) containing the code and 2 image files
(Samplel and Sample2) containing different sample input/output of the program.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9456d33b-7da7-418b-baa4-da360d928341%2Fb9853b65-51c9-46bf-ad21-85382b77d999%2Fx1vhlvq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
please put comments on these line of codes of what these do:
private static void evenNumbersAboveDiagonal(int[][] arr) {
for(int j=1;j<5;j++){
for(int i=j-1;i>=0;i--){
if(arr[i][j]%2 == 0)
System.out.print(arr[i][j] + " ");
}
}
System.out.println();
}
private static void oddNumbersBelowDiagonal(int[][] arr) {
for(int i=0;i<5;i++){
for(int j=0;i>j;j++){
if(arr[i][j]%2==1)
System.out.print(arr[i][j] + " ");
}
}
System.out.println();
}
private static int sumOfElementsAboveDiagonal(int[][] arr) {
int sum = 0;
for (int j=1;j<5;j++) {
for (int i=j-1;i>=0;i--) {
sum += arr[i][j];
}
}
return sum;
}
private static int sumOfElementsBelowDiagonal(int[][] arr) {
int sum = 0;
for(int i=0;i<5;i++){
for(int j=0;i>j;j++) {
sum += arr[i][j];
}
}
return sum;
}
private static void elementsOfMainDiagonal(int[][] arr) {
for (int i=0;i<5;i++) {
for (int j=0; j<5;j++) {
if(i == j)
System.out.print(arr[i][j] + " ");
}
}
System.out.println();
}
private static int sumOfPrime(int[][] arr) {
int sum = 0;
for(int i=0;i<5;i++){
for(int j=0;j<5;j++) {
if(isPrime(arr[i][j]))
sum+=arr[i][j];
}
}
return sum;
}
private static boolean isPrime(int n){
if(n<=1)
return false;
for(int i=2;i<n;i++)
if(n%i == 0)
return false;
return true;
}
}
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)