I need help to Fill in the two methods in the .java file in the following below:
I need help to Fill in the two methods in the .java file in the following below:
public class JavaProject
{
public static int[][] sum(int[][] A, int[][] B)
{
//TODO: Your code should go here
return null; //This line is wrong and should be changed.
}
public static int[][] cutOffTheCrust(int[][] input)
{
//TODO: Your code should go here
return null; //This line is wrong and should be changed.
}
public static int[][] getSubsetRows(int[][] input, int row_start, int row_end)
{
//TODO: Your code should go here
return null; //This line is wrong and should be changed.
}
public static void main(String[] args)
{
System.out.println("=== TESTING sum Test 1 ===");
int[][] input1 = {{1, 5},
{4, 6}};
int[][] input2 = {{7, 3},
{5, 4}};
int[][] result = sum(input1, input2);
printArray(result);
System.out.println("=== TESTING sum Test 2 ===");
int[][] input7 = {{1, 5, 1, 0},
{4, 6, -3, 7}};
int[][] input8 = {{7, 3, 1, 1},
{5, 4, 0, -2}};
result = sum(input7, input8);
printArray(result);
System.out.println("=== TESTING cutOffTheCrust Test 1===");
int[][] input3 = {{1, 5, 2, 7, 3, 7},
{4, 6, 3, 2, 5, 4},
{2, 4, 2, 2, 4, 8},
{3, 4, 6, 7, 9, 6}};
result = cutOffTheCrust(input3);
printArray(result);
System.out.println("=== TESTING cutOffTheCrust Test 2===");
int[][] input4 = {{0, 0, 0, 0},
{0, 7, 7, 0},
{0, 7, 7, 0},
{0, 0, 0, 0}};
result = cutOffTheCrust(input4);
printArray(result);
System.out.println("=== TESTING getSubsetRows Test 1 ===");
int[][] input5 = {{8, 3, 2, 1, 2},
{4, 4, 3, 5, 5},
{9, 5, 8, 2, 4},
{2, 7, 2, 2, 1},
{0, 7, 4, 9, 1}};
int row_start = 1;
int row_end = 5;
result = getSubsetRows(input5, row_start, row_end);
printArray(result);
System.out.println("=== TESTING getSubsetRows Test 2 ===");
int[][] input6 = {{1, 5, 2, 7, 3, 7},
{4, 6, 3, 2, 5, 4},
{2, 4, 2, 2, 4, 8},
{3, 4, 6, 7, 9, 6}};
row_start = 0;
row_end = 2;
result = getSubsetRows(input6, row_start, row_end);
printArray(result);
}
public static void printArray(int[][] m)
{
if(m == null)
return;
for(int r=0; r<m.length; r++)
{
for(int c=0; c<m[0].length; c++)
{
System.out.printf("%4d", m[r][c]);
}
System.out.println();
}
}
}

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









