import java.util.Arrays; public class DiverseArray { public static int arraySum(int[] arr) { // part(a) } public static int[] rowSums(int[][] arr2D) { // part(b) } public static boolean isDiverse(int[][] arr2D) { // part(c) } public static void main (String[] args) { int[][] mat1 = { { 1, 3, 2, 7, 3}, {10, 10, 4, 6, 2}, { 5, 3, 5, 9, 6}, { 7, 6, 4, 2, 1} }; int[][] mat2 = { { 1, 1, 5, 3, 4}, {12, 7, 6, 1, 9}, { 8, 11, 10, 2, 5}, { 3, 2, 3, 0, 6} }; int[] arr1 = mat1[0]; System.out.println("Part(a)\narr1= [1,3,2,7,2]\narraySum(arr1) should be 16, your code: "+arraySum(arr1)); System.out.println("Part (b): \nmat1 is "); for(int i=0; i< mat1.length; i++) { System.out.println(Arrays.toString(mat1[i]) ); } System.out.println("rowSums(mat1) should be [16,32,28,20]-your code: "+Arrays.toString(rowSums(mat1))); System.out.println("\nmat2 is "); for(int i=0; i< mat1.length; i++) { System.out.println(Arrays.toString(mat2[i]) ); } System.out.println("rowSums(mat2) should be [14,35,36,14]-your code: "+Arrays.toString(rowSums(mat2))); System.out.println("Part (c)\nisDiverse(mat1) should be true - your code: "+ Boolean.toString(isDiverse(mat1) )); System.out.println("Part (c)\nisDiverse(mat2) should be false - your code: "+ Boolean.toString(isDiverse(mat2) )); } }