Question: Please use all methods and data members and constructors in the question!!! Two matrices can be added or subtracted if they have the same size.


![size. Suppose A ai] and B [bi] are two matrices of the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f5284bb84ce_66766f5284b2aa44.jpg)
Please use all methods and data members and constructors in the question!!!
Two matrices can be added or subtracted if they have the same size. Suppose A ai] and B [bi] are two matrices of the size mx n, in which ai denotes the element of A in the ith row and the jth column, and so on. The sum and difference of A and B are given by: The multiplication of A and B (A B) is defined only if the number of columns of A is the same as the number of rows of B. If A is of the size mx n and B is of the size nx t, the A B C (represented by [cik]) is of the size m x t and the element cik is given by the formula Create a class Matrix with the following // data members private final int[l[] values; private final String name holds the matrix values // holds the matrix name // constructors public Matrix (String name, intl values) ) public Matrix(int[][] valuesI/ name is set to null // methods public Matrix add (Matrix m) / returns null if operation is not possible else this plus m public Matrix sub (Matrix m) public Matrix mult (Matrix m) // returns null if operation is not possible else this times m public string getName // returns null if operation is not possible else this minus m // returns the matrix name // toString override. Make sure the @Override annotation is there too // Use a StringBuffer to construct the matrix output with a Formatter to use a field width of 3 // for each matrix value and with each value on a row separated by one space. If name is not // null, then output the name with the format name: on the first output line. Output the matrix // values as a 2D table with aforementioned formatting. Note that with this override, you can // simply output a Matrix m using System.out.println (m)i @Override public String toString ) // output name and values in a table see example Create a test class TestMatrix (in the Netbeans Test Packages source folder) that reads up to ten (10) integer matrices from input file matrices.txt and creates an array of Matrix objects that represent them (hint: you should use a while loop for this!). Each matrix in the input file consists of a line with the matrix name, number of rows and number of columns, followed by a line for each row. Note that you
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
