Page 1 :
Friday, September 03, 2021, 8:12 PM, , COMBINED ISC 135 Page 1
Page 4 :
A class Matrix contains a two-dimensional integer, array of an order [m * n]. The maximum value, possible for both ‘m’ and ‘n’ is 25. Design a class, Matrix to find the difference between the two, COMBINED ISC 135 Page 4
Page 5 :
Matrix to find the difference between the two, matrices. The details of the members of the class are, given below:, Class name: Matrix, Data members/instance variables:, arr[][]: stores the matrix element, m: integer to store the number of rows, n: integer to store the number of columns, Member functions:, Matrix (int mm, int nn): to initialize the size of the, matrix m = mm and n = nn, void fillarray(): to enter the elements of the matrix, Matrix SubMat(Matrix A): subtract the current object, from the matrix of the parameterized object and, return the resulting object, void display(): display the matrix elements, , Specify the class Matrix giving details of the, constructor(int, int), void fillarray(), Matrix SubMat, (Matrix) and void display (). Define the main ( ), function to create objects and call the methods, accordingly to enable the task., , import java.util.*;, class matrix, {, int a[][],m,n;, matrix(int mm,int nn), {, m=mm;, n=nn;, a=new int[m][n];, }, void fillarray(), {, Scanner sc=new Scanner(System.in);, int i,j;, for(i=0;i<m;i++), {, for(j=0;j<n;j++), a[i][j]=sc.nextInt();, }, }, matrix submat(matrix A), {, matrix diff=new matrix(m,n);, , COMBINED ISC 135 Page 5
Page 6 :
int i,j;, for(i=0;i<m;i++), {, for(j=0;j<n;j++), diff.a[i][j]=A.a[i][j]-this.a[i][j];, }, return diff;, }, void display(), {, int i,j;, for(i=0;i<m;i++), {, for(j=0;j<n;j++), System.out.print(a[i][j]+" ");, System.out.println();, }, }, public static void main(), {, matrix X=new matrix(3,4);, matrix Y=new matrix(3,4);, matrix Z=new matrix(3,4);, System.out.print("Enter first matrix");, X.fillarray();, System.out.print("Enter second matrix");, Y.fillarray();, Z=Y.submat(X);, System.out.println("first matrix");, X.display();, System.out.println("Second matrix");, Y.display();, System.out.println("Differenc matrix");, Z.display();, }, }, , A class Combine contains an array of integers, which combines two arrays into a single array, including the duplicate elements, if any, and sorts, the combined array. Some of the members of the, class are given below: [10], Class name: Combine, Data Members/instance variables:, com[ ]: integer array, size: size of the array, Member functions/methods:, Combine(nt nn): parameterized constructor to, assign size = nn, void inputarray(): accepts the array elements., void sort(): sorts the elements of the combined, , COMBINED ISC 135 Page 6
Page 7 :
array in ascending order using the selection sort, technique., void mix(Combine A, Combine B): combines the, parameterized object arrays and stores the result, in the current object array along with duplicate, elements, if any., void display(): displays the array elements, Specify the class Combine giving details of the, constructor (int), void inputarray(), void sort(),, void mix (Combine, Combine) and void display ()., Also, define the main() function to create an, object and call the methods accordingly to enable, the task., Answer:, Import java. io, , void mix(Combine A, Combine B), {, , COMBINED ISC 135 Page 7