Answered! I have my program written and i just need help writing the test for it below are the instructions for the test…

I have my program written and i just need help writing the test for it below are the instructions for the testimport java. util. Scanner; public class Transpose static void createPatterned2DArray (int arr []ll) t if (arr null) return for (int i 0; i arr. length; ++i) for (int j J 0; j arr [i] length; ++j) t arr [i] [j] 10 arr. length (i 1) j static void print2DArray (int arr if (arr null) return for (int i 0; i arr. length; ++i) t System out un for (int j 0; j arrlil. length; ++j) t System out print (arr [i] [j]

Expert Answer

 Program code:

import java.util.Scanner;
public class Transpose
{
static void createPatterned2DArray(int arr[][]) //function of creating array
{
if(arr==null)
return;
for(int i=0;i<arr.length;++i)
{
for(int j=0;j<arr[i].length;++j)
{
arr[i][j] = 10+arr.length*(i+1)+j;
}
}
}
static void print2DArray(int arr[][]) //print the array
{
if(arr == null)
return;
for(int i=0;i<arr.length;++i)
{
System.out.println();
for(int j=0;j<arr[i].length;++j)
{
System.out.print(arr[i][j]+” “);
}
}

}
static void print2DArrayTransposed(int arr[][]) //function for array transposed
{
if(arr == null)
return;
System.out.println();
for(int j=0;j<arr[0].length;++j)
{
System.out.println();
for(int i=0;i<arr.length;++i)

{
System.out.print(arr[i][j]+” “);
}
}

}
public static void main(String[] args) //main function
{

Scanner sc = new Scanner(System.in);
System.out.print(“Enter row and column: “);
int row = sc.nextInt();
int cols = sc.nextInt();
int arr[][] = new int[row][cols]; //instance of variables

createPatterned2DArray(arr); //calling create function
System.out.println(“Created Array “);
print2DArray(arr); //calling print function
System.out.println(“nnTransposed Array “);
print2DArrayTransposed(arr); //calling transpose function

}
}

Output:

Still stressed from student homework?
Get quality assistance from academic writers!