Write a Java Program to Add Two Matrices.
import java.util.Scanner;
public class AddMatrices {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of rows and columns for the matrices:");
int rows = scanner.nextInt();
int cols = scanner.nextInt();
int[][] matrix1 = new int[rows][cols];
int[][] matrix2 = new int[rows][cols];
int[][] sumMatrix = new int[rows][cols];
System.out.println("Enter the elements of __________ __________ ______ ____ ________.
___ __________ __________ ___ _________ _________ ________ _____ _____ ________ __________.
____ _____ _________ _____ ___ ________.
________ ______ __________ __________ ____ ___ ___.
_______ ________ ___ __________ _______.
___ ______ ___ _________ _____ _________ ________ ______ _____ _______ _________ ___.
_________ _____ ______ _______ _______ _____ ______ __________ _____ ______ ____ ____.
______ __________ ___ __________ _________ ___.
_______ ________ __________ ___ _______ _____ _________ __________ ____ ______ ___.
__________ ________ __________ ___ _______ ______.
____ __________ __________ __________ ________ ________ ____ __________ ____ _____.
____ ______ ________ ______ _____ _______ ______ ____ _______ _______ ______.
_____ _________ ________ ________ _________ __________ _______ _______ ____ ______ ______.
_______ _______ __________ ______ ______ __________ ________ __________.
_________ ______ _____ ___ _________ ___ _____ _________ ____ ___.
_____ _______ _____ __________ ___ ____ ________ __________ _________ ____.
____ ___ ________ ___ ______ ________ __________ _________ ______ ______ _________.
_________ _______ ___ ____ ________ ______ ___.
___ __________ _______ ______ ____ ____ _________.
____ ___ ________ ________ ___ _________ ___ _________ _______ ________ ___.
________ ______ ____ __________ ____ ____ ___ _________ ____ ____ _________.
__________ ____ ________ _______ __________ __________ ____ _______.
_________ ____ ____ _______ __________ __________ __________ _____ _________ _______.
_____ ____ ___ ___ __________ ___ ___ _________ _____ _______.
____ _________ ____ _______ _________.
___ _______ __________ ___ ____.
___ ___ ______ _____ ____ ___ _______.
______ ___ _______ ___ _____ _______ ________.
___ ________ ____ ______ ______ ____ _______ ________ ______ __________ _________ _________.
_______ ___ ____ _______ _____ _________ _______ ______ __________ _________.
_____ ___ _______ ______ _____.
_____ __________ ______ _______ ___ _________ ____.
_______ ______ _____ _______ ________ __________ ____ ___ ______ ____.
___.
Get Full Answer on WhatsApp