-
Notifications
You must be signed in to change notification settings - Fork 0
/
ass1_7.java
57 lines (46 loc) · 905 Bytes
/
ass1_7.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Scanner;
class matrix
{
int a[][]=new int[3][3];
int b[][]=new int[3][3];
int c[][]=new int[3][3];
void getInfo(Scanner sc)
{
System.out.println("Enter matrix a: ");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=sc.nextInt();
System.out.println("Enter matrix b: ");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
b[i][j]=sc.nextInt();
}
void multiply()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
for(int k=0;k<3;k++)
c[i][j]+=a[i][k]*b[k][j];
}
void display()
{
System.out.println("Matrix after multplication is: ");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(c[i][j]+" ");
System.out.println();
}
}
}
class ass1_7
{
public static void main(String s[])
{
matrix m=new matrix();
Scanner sc=new Scanner(System.in);
m.getInfo(sc);
m.multiply();
m.display();
}
}