Do not change main Just fill in this method below main addMatricies() Don't change any other code or write any other methods The output of your program should look like this: MATRIX1 1 2 3 2 4 6 MATRIX2 4 6 8 6 9 12 MATRIX1 + MATRIX2 5 8 11 8 13 18 /* Exercise2.java */ import java.io.*; import java.util.*; public class Exercise2 { public static void main( String[] args ) { try // We wil learn about Exceptions soon { int[][]m1 = new int[2][3]; int[][]m2 = new int[2][3]; int[][]m3 = new int[2][3]; // put some numbers in m1 for (int r=0; r< matrix[row].length ; ++col ) System.out.print( matrix[row][col] + " "); System.out.println(); // newline after each row } // END FOR EACH ROW System.out.println(); // puts a blank line betwen next printout } // END PRINTMATRIX } // END CLASS
Explanation / Answer
package com.cramster.nov9; /* Exercise2.java */ import java.io.*; import java.util.*; public class Exercise2 { //NOTE THE CODE POSTED IN THE UESTION SEEMS TO BE MISSING //I am just guessing that this might be your MAIN program. //Anyway you should be able to use the addmatrices() method even if the MAIN program differs public static void main( String[] args ) { int[][]m1 = new int[2][3]; int[][]m2 = new int[2][3]; int[][]m3 = new int[2][3]; // put some random numbers in m1,m2,m3 Random random = new Random(); for (int r=0; r