Question

Write java program to find sum of two matrices. Define appropriate class, constructor and methods in your program. Make necessary assumptions.

07 Aug 2023
Answer :
Word Count : 614

Here's a Java program that calculates the sum of two matrices using classes, constructors, and methods:


class Matrix {
    private int rows;
    private int cols;
    private int[][] data;

    public Matrix(int rows, int cols) {
        this.rows = rows;
        this.cols = cols;
        this.data = new int[rows][cols];
    }

    public void setData(int[][] data) {
        this.data = data;
    }

    public void inputMatrix() {
        System.out.println("Enter matrix elements:");
        Scanner scanner = new Scanner(System.in);
     

_______ __________ _________ ___ ____ ____ _________ _____ ________ _______ _____ ____.
___ _____ ____ _______ ___ _____ _______ _________ _____ _________ ____ ______.
_______ _________ ___ _________ _____ _______ ______ ______.
__________ _____ ______ __________ __________ _________ ____ __________ ______.
_______ _______ ___ _______ ______ _______ ___ _________.
__________ _____ ____ ____ _____ ________ _____ _______ ________.
_________ _________ ______ ___ _______.
________ ________ _____ ______ ___ ___ ____ ___ ____ _______.
__________ _______ _____ ___ __________ _____ _____ ________ ____ _______.
______ ___ ________ _____ ______ _____ ________ ______ ___ _________ __________.
___ _______ _________ ______ _______ _______.
_____ ____ _____ _________ ____ _______ ________ _________ _____ _______ ______.
_________ _________ ____ __________ ____ _________ _________ ___ _________ ____ _______.
___ _______ ___ ________ ____ ____ _________ _______ ___ ______.
________ ___ ___ _________ ___.
__________ ________ ________ ___ __________ __________ ____ ______.
__________ ____ __________ ________ _____ _________ ___ _____ __________ ________ _______ __________.
_____ ______ ___ ______ ___ ______ ______ ____ _______ _________ ___.
___ ________ ________ _________ ____ ______ ________ __________.
____ ________ ___ __________ _______ ______ ________ ______.
__________ _______ ____ ________ _______ _____ _____ _______ ___ ______.
_____ _____ _____ _________ ________ _______ __________.
_____ ________ _________ ______ _______.
_______ ________ __________ ____ __________ __________ ______.
____ ________ _________ ___ _____ _________ _____ __________ _____ ________ ____ ____.
_________ __________ ________ _____ ____ _________ _________ _____ ________ _____ ____ _____.
___ ______ __________ ______ ___ _______ ________.
____ __________ ______ _______ ____ _______ __________ _________ _____.
___ ___ _______ ____ __________ _________.
_________ ____ ___ ____ ______ _________ ____ _________ _____ ________ _____.
_________ ________ ____ ________ ____ ________ ___ _______ ____.
___ ______ __________ __________ _________ ________ __________ __________ _____ ___ ________.
____ ___ __________ _______ _____ ___ _________ ______.
___ __________ __________ ____ _____ __________ ___ ____ _______ ____ ________.
______ ______ _______ ________ ___ ______ _____ ___ ________.
________ _______ ___ _______ _______ ________ _______ __________ __________ _______ ____.
__________ _________ _____ _____ ________ _________ ____ ___ _____.
________ __________ ___ _______ _____ _____ __________ __________ __________ ___.
_____ ________ ________ ________ _____.
_____ ______ _______ ______ ________ __________.
_______ _______ ______ _____ _________ ___ _________ _______ _________.
_________ _______ __________ _________ ___ _______ __________ ____ __________.
____ _____ ____ _________ __________ ____ _________.
________ _______ _____ ___ _____ ___ ________ ________ ______ _____ ____.
__________ ________ ________ _________ ____ __________ ________ _________ _______ __________.
_________ _____ ___ ______ ___ _____.
______ _________ ________ __________ __________ _______.
________ _____ ______ _________ _____ ________ ___ ____ ____ ________.
______ ______ ____ __________ ________.
___ ____ __________ __________ _________.
__________ _________ __________ __________ ____.
____ _________ _____ _________ ________ ___ _______ ___ _______ _________ ____ _________.
____ _____ _______ _____ _____ _________ _______ ______ __________ ___ ________.
____ ____ __________ _________ ________ __________ _______ ___.
_____ ________ __________ ______ _____ ___.
_____ ______ ____ ________ ________ _________ _____ ____ _____ _______ ______ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCSL 43 2023 2024 - Write java program to find sum of two matrices. Define appropriate cla | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→