Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package processor;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n; //rows
- int m; //columns
- //capture matrixA
- n = scanner.nextInt();
- m = scanner.nextInt();
- Matrix matrixA = new Matrix(n, m); //define empty matrix with correct dimensions
- matrixA.readMatrix();
- //matrixA.print(); //test matrixA
- //capture matrixB
- n = scanner.nextInt();
- m = scanner.nextInt();
- Matrix matrixB = new Matrix(n, m);
- matrixB.readMatrix();
- /* matrixB.print(); //test matrixB */
- if (matrixA.rows != matrixB.rows && matrixA.columns != matrixB.columns) {
- System.out.println("ERROR");
- } else {
- Matrix matrixC = matrixA.addMatrix(matrixB);
- matrixC.printMatrix();
- }
- }
- }
Add Comment
Please, Sign In to add comment