1). Create the class called ArrayOperations2D and include the method findRowMax below public class ArrayOperations2D { public static intl] findRowMax (int [][] anArray) int [] max = new int [anArray. length]; //for each row for (int i=0; i< anArray. length; i++) int largest = anArray [1][0]; for (int i=0; < anArray [i].langthi i++) if (anArray[i](j] > largest) largest = anArray[illjl: max [i]=largest; } return max; 2). Include the method called findRowSums below public static int[] findRowSums (int [] [] anArray) int [] rowSums = new int [anArray.length]; for (int i=0; i< anArray.length; i++) int sum = 0; for (int j=0; j<anArray(jl.length; J++) sum+=anArray [i][jl; rowSums [1] =sum; } return rowSums; 3). Add a method called findColumnMax to the class. This method should find and return the maximum value in each column of the two dimensional array 4). Add a method called findColumnSum that calculates and returns the sum of each column. 5). Add a method called findTranspose that finds and returns the transpose of a two dimensional matrix. Recall that the transpose of a matrix is the original matrix with the rows and columns reversed. If the original matrix has n rows and m columns, the transpose will have m rows and n columns. 6). The signature of the findTranspose method should be: public int[][] findTranspose(int[][] myArray) As the signature indicates, you will pass findTranspose a 2D array and you will return a 2D array. 7). The dimensions of myArray are myArray.length rows and myArray[0].length columns. Thus the dimensions of the transpose will be myArray[0].length rows and myArray.length columns. 8). Use the code below to create a class that contains the test program for findRowMax and findRowSums that prints row maximums and row sums. Add code to test your method findColumnMax. Add code to test your method findColumnSums. public class ArrayTest public static void main (String[] args) int myArray[1 [1 =((), , (), ()): Printing the array Int[ l]columv = ArrayOperations2D.findColumn (myArray) ; for (int i=0; i< column. length; i++) System.out-println("Max in row "+ i System. out printin() ; int [] columnSums = ArrayOperations2D. findColumnSums (mAArray) : for (int i=0; i< rowSums. length; i++) System.out .println ("Sum of in row "+ i + “ =+ rowSums [i]) 9). Add code to test your method to calculate the transpose. Call the findTranspose method to obtain the transpose of the 2D array shown in the test class. Print the transpose array 10). Finally, write a test method that will: Creates an array with the three rows {1,4,3,2}, (2,4,8,6} and {3,3,3,3}. Print the max and minimum values of each row and of each column. Print the sum of each row and column. Print the transpose of the matrix.
1). Create the class called ArrayOperations2D and include the method findRowMax below
public class ArrayOperations2D
{
public static intl] findRowMax (int [][] anArray)
int [] max = new int [anArray. length];
//for each row
for (int i=0; i< anArray. length; i++)
int largest = anArray [1][0];
for (int i=0; < anArray [i].langthi i++)
if (anArray[i](j] > largest)
largest = anArray[illjl:
max [i]=largest;
}
return max;
2). Include the method called findRowSums below
public static int[] findRowSums (int [] [] anArray)
int [] rowSums = new int [anArray.length];
for (int i=0; i< anArray.length; i++)
int sum = 0;
for (int j=0; j<anArray(jl.length; J++)
sum+=anArray [i][jl;
rowSums [1] =sum;
}
return rowSums;
3). Add a method called findColumnMax to the class. This method should find and return the maximum value in each column of the two dimensional array
4). Add a method called findColumnSum that calculates and returns the sum of each column.
5). Add a method called findTranspose that finds and returns the transpose of a two dimensional matrix. Recall that the transpose of a matrix is the original matrix with the rows and columns reversed. If the original matrix has n rows and m columns, the transpose will have m rows and n columns.
6). The signature of the findTranspose method should be:
public int[][] findTranspose(int[][] myArray)
As the signature indicates, you will pass findTranspose a 2D array and you will return a 2D array.
7). The dimensions of myArray are myArray.length rows and myArray[0].length columns. Thus the dimensions of the transpose will be myArray[0].length rows and myArray.length columns.
8). Use the code below to create a class that contains the test program for findRowMax and findRowSums that prints row maximums and row sums.
Add code to test your method findColumnMax.
Add code to test your method findColumnSums.
public
class ArrayTest
public static void main (String[] args)
int myArray[1 [1 =((), , (), ()):
Printing the array
Int[ l]columv = ArrayOperations2D.findColumn (myArray) ;
for (int i=0; i< column. length; i++)
System.out-println("Max in row "+ i
System. out printin() ; int []
columnSums = ArrayOperations2D. findColumnSums (mAArray) :
for (int i=0; i< rowSums. length; i++)
System.out .println ("Sum of in row
"+ i + “ =+ rowSums [i])
9). Add code to test your method to calculate the transpose.
- Call the findTranspose method to obtain the transpose of the 2D array shown in the test class.
- Print the transpose array
10). Finally, write a test method that will:
- Creates an array with the three rows {1,4,3,2}, (2,4,8,6} and {3,3,3,3}.
- Print the max and minimum values of each row and of each column.
- Print the sum of each row and column.
- Print the transpose of the matrix.
Unlock instant AI solutions
Tap the button
to generate a solution