package SolveProblem;
import java.util.Scanner;
public class MultiplicationOfTwoMatrics {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
int m,n,p,q;
int first[][]=new int[10][10];
int second[][]=new int[10][10];
int result[][]=new int[10][10];
System.out.println("Enter first matrics row and column : ");
m=myScanner.nextInt();
n=myScanner.nextInt();
System.out.println("Enter second matrics row and column : ");
p=myScanner.nextInt();
q=myScanner.nextInt();
if (n!=p) {
System.out.println("Multiplication impossible , Please enter valid num :");
} else {
System.out.println("Enter first matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
first[i][j]=myScanner.nextInt();
}
}
System.out.println("Enter second matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
second[i][j]=myScanner.nextInt();
}
}
int sum=0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < q; j++) {
for (int j2 = 0; j2 < p; j2++) {
sum=sum+(first[i][j2]*second[j2][j]);
}
result[i][j]=sum;
sum=0;
}
}
System.out.println("Multiplication of the given matrics is : ");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(result[i][j]+"\t");
}
System.out.println();
}
}
}
}
import java.util.Scanner;
public class MultiplicationOfTwoMatrics {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
int m,n,p,q;
int first[][]=new int[10][10];
int second[][]=new int[10][10];
int result[][]=new int[10][10];
System.out.println("Enter first matrics row and column : ");
m=myScanner.nextInt();
n=myScanner.nextInt();
System.out.println("Enter second matrics row and column : ");
p=myScanner.nextInt();
q=myScanner.nextInt();
if (n!=p) {
System.out.println("Multiplication impossible , Please enter valid num :");
} else {
System.out.println("Enter first matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
first[i][j]=myScanner.nextInt();
}
}
System.out.println("Enter second matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
second[i][j]=myScanner.nextInt();
}
}
int sum=0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < q; j++) {
for (int j2 = 0; j2 < p; j2++) {
sum=sum+(first[i][j2]*second[j2][j]);
}
result[i][j]=sum;
sum=0;
}
}
System.out.println("Multiplication of the given matrics is : ");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(result[i][j]+"\t");
}
System.out.println();
}
}
}
}
1 comments:
commentsMultiplication Of Two Matrics In Java - Education Help >>>>> Download Now
Reply>>>>> Download Full
Multiplication Of Two Matrics In Java - Education Help >>>>> Download LINK
>>>>> Download Now
Multiplication Of Two Matrics In Java - Education Help >>>>> Download Full
>>>>> Download LINK