Page 590 - Computer science 868 Class 12
P. 590
Program 9 Product of two matrices
Write a program to multiply two Product object and print the result using the concept of
matrix multiplication.
Class name : Product
Data Members
int mat[][] : to store matrix
int s : size of matrix
Member Function
Product(int a) : parameterised constructor to input the size of the matrix
and to declare the matrix
void input() : to accept numbers in the matrix
product prod(product p1,
product p2) : multiply product object p1 and p1 and return result
void display() : display the result
1 import java.util.*;
2 class product
3 {
4 int mat[][],s;
5 product(int a)
6 {
7 s=a;
8 mat=new int[s][s];
9 }
10 void input()
11 { // accept numbers
12 Scanner sc=new Scanner(System.in);
13 for(int i=0;i<s;i++)
14 {
15 for(int j=0;j<s;j++)
16 {
17 mat[i][j]=sc.nextInt();
18 }
19 }
20 }
21 product prod(product p1,product p2)
22 {
588588 Touchpad Computer Science-XII

