Question: Write a method to add two matrices. The header of the method is as follows: public static double[][] addMatrix(double[][] a, double[][] b) In order to
Write a method to add two matrices. The header of the method is as follows:
public static double[][] addMatrix(double[][] a, double[][] b)
In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements. Let c be the resulting matrix. Each element cij is aij + bij. For example, for two 3 * 3 matrices a and b, c is
Write a test program that prompts the user to enter two 3 * 3 matrices and displays their sum. Here is a sample run:
12 + b12 + b13 a22 + b22 a23 + b23 2 + b32 + b33, a11 + b1 a2i + bz1 + b1 b12 b13 b2 b23 b31 a12 b11 a13 + | b21 a21 a22 2 a23 b32 b3, 1 -Enter Enter matrix1: 1 2 3 4 5 6 7 8 9 Enter matrix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2 -Enter The matrices are added as follows 1.0 2.0 3.0 4.0 5.0 6.0 + 7.0 8.0 9.0 0.0 2.0 4.0 1.0 4.5 2.2 1.1 4.3 5.2 1.0 4.0 7.0 5.0 9.5 8.2 8.1 12.3 14.2
Step by Step Solution
3.34 Rating (160 Votes )
There are 3 Steps involved in it
Java program for adding two matrices Header file section Class declartions class public stati... View full answer
Get step-by-step solutions from verified subject matter experts
