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 ______ __________ ____ __________ _______ __________ ________ _______ ______.
____ ____ _______ _________ __________ ___ ____.
_______ ________ ______ ___ ____ _____ _________ ______ _____ ____ __________.
_______ ___ ________ ______ _________ ____ _______ ________.
_____ ______ _________ ________ _________ __________ ________ __________ _____ ______ ______.
_______ _______ ___ ________ __________ _____ ____ _________ ________.
__________ _________ _____ ___ _________ _______ ____ ______ __________ ________ _________ ___.
___ ________ _______ ________ ________ __________ ___ _________ ___.
____ ___ __________ __________ _______ _______ ________ ________ _________ _____.
___ ______ ______ ______ __________ ________ _________ ________.
_________ _________ _______ _______ ____ _________ ___.
______ _____ _____ ________ ________ ____ __________ _________.
______ _____ ______ ____ ___ ______ ____ _______.
_______ ______ __________ __________ ________ ______ _________.
________ ____ _________ ____ _____ _____ ______ ____ _____.
___ _______ _________ _______ ___ ___ __________ __________.
____ ______ ________ ___ _______ ______ __________ _______.
________ ______ _________ ______ ____ ________ __________ ________ ________ ____ _____.
________ _____ __________ __________ ___ ___ _____ ____.
____ _____ ___ ___ ___ _____ _____ __________ ___ _______ ____.
_______ ________ __________ ____ ________ _____ ________ _________ ______ ________ ____.
______ ___ _______ ____ _________ ___ ______ __________ ________ ______ ____ __________.
________ ___ _________ ____ _______ ______ ___ ______.
____ ____ ___ ______ ______ ________ __________ _______ ___ ______.
________ ____ ________ ___ __________ __________ ____ ________.
_________ ______ _______ ______ _____ _________ ____.
_______ _____ _______ ___ _____ _____ ___ _____.
____ ________ _________ ___ ___ ________ ____ _________ ___ _____ ______ ________.
_____ _______ _____ ________ _______.
_______ _______ _______ __________ _______ ______ __________.
_______ _______ ____ ______ ______.
____ __________ ____ _________ _________ ________ _________ _____.
_______ ____ _______ _____ __________ __________ ______ ______ ___ __________ ________.
_____ _____ _______ _____ ______ _____ _______ _____ _____.
________ _____ ____ ________.
Get Full Answer on WhatsApp