Question: Write a method to multiply two matrices. The header of the method is:public static double[][]multiplyMatrix(double[][] a,?double[][] b)To multiply matrix a by matrix b, the number
Write a method to multiply two matrices. The header of the method is:public static double[][]multiplyMatrix(double[][] a,?double[][] b)To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let cbe the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 ? b1j + ai2 ? b2j + c + ain ? bnj.For example, for two 3 ? 3 matrices a and b, c is

where cij = ai1 ? b1j + ai2 ? b2j + ai3 ? b3j.Write a test program that prompts the user to enter two 3 ? 3 matrices and displays their product. Here is a sample run:
C13 C12 C11 b12 b13 b11 b2 b23 b32 b33, C23 C22 a13 a12 C21 | b A22 C32 C31 C3. b31 . 2 1 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 multiplication of the matrices is 0 2.0 4.0 1 4.5 2.2 1.1 4.3 5.2 -Enter 5.3 23.9 24 11.6 56.3 58.2 17.9 88.7 92.4 1 2 3 4 5 6 7 8 9
Step by Step Solution
3.50 Rating (170 Votes )
There are 3 Steps involved in it
Program Plan Create a class Multiplying matrices that accepts two matrices Get the input matrix elem... View full answer
Get step-by-step solutions from verified subject matter experts
