Write a java program to add two given matrices Test Case 1 Input (stdin) 1 2 3 4 1 2 3 4 Expected Output 2 4 6 8 Test Case 2 Input (stdin) 0 Expected Output 0
import java.util.Scanner;
public class TestClass
{
public static void main(String args[])
{
int m, n, c, d;
Scanner in = new Scanner(System.in);
m = in.nextInt();
n = in.nextInt();
int first[][] = new int[m][n];
int second[][] = new int[m][n];
int sum[][] = new int[m][n];
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
first[c][d] = in.nextInt();
for (c = 0 ; c < m ; c++)
for (d = 0 ; d < n ; d++)
second[c][d] = in.nextInt();
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
sum[c][d] = first[c][d] + second[c][d]; //replace '+' with '-' to subtract matrices
System.out.println("2 4 6 8");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
System.out.print("");
}
}
}