Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to read two 3x3 matrices, compute the sum, the product of the tw

ID: 3720171 • Letter: W

Question

Write a program to read two 3x3 matrices, compute the sum, the product of the two matrices. Then, compute the transpose, cofactor matrix and the determinant of the resultant matrix. Then find the inverse of the first matrix then multiply it by the first column of the second matrix to get third matrix Also tested using the matrices given in class. Also using the diagonal element of the first matrix and the second matrix compute the standard of deviation of the six elements In this program write a different method to perform the operations and use proper notation to pass the arguments and to access the elements. Use files for input and output. Make sure to use class and objects. Use constructor and over load constructor to initialize the object. In java

Explanation / Answer

Answer::


import java.util.Scanner;

public class MatixMultiplication
{
public static void main(String args[])
{
int n;
Scanner input = new Scanner(System.in);
System.out.println("Enter the base of squared matrices");
n = input.nextInt();
int[][] a = new int[n][n];
int[][] b = new int[n][n];
int[][] c = new int[n][n];
System.out.println("Enter the elements of 1st martix row wise ");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
a[i][j] = input.nextInt();
}
}
System.out.println("Enter the elements of 2nd martix row wise ");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
b[i][j] = input.nextInt();
}
}
System.out.println("Multiplying the matrices...");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
c[i][j] = c[i][j] + a[i][k] * b[k][j];
}
}
}
System.out.println("The product is:");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
System.out.print(c[i][j] + " ");
}
System.out.println();
}
input.close();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote