Matrix multiplication is not commutative


Matrix multiplication is not commutative. That is, if A and B are each n×n matrices, then it is not always true that AB=BA.

Write a program that does the following.

1. Inputs an integer n and checks that it is positive.
2. Creates two n×n double matrices A and B.
3. Inputs in values for A and B.
4. Computes and prints both AB and BA.
5. Computes and prints AB-BA.
6. Prints whether the matrices were commutative or not.
7. Inputs an integer p and checks that it is positive.
8. Prints Aj-Bj and (A-B)j, for j=1,2,..p. 

Your program must contain a method

public static void matMult(int n, double[][]A, double[][]B, double[][]C)


You may use the one from the notes. This method must be called for each multiplication.

Whenever the user is to input values, a prompt must be printed.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Matrix multiplication is not commutative
Reference No:- TGS0144502

Expected delivery within 24 Hours