When you are adding two matrices together, you add similar elements together and place them in a new matrix. Because of this, you need to have matrices with identical sizes. Create a Matrix class, with methods such as add(Matrix a), subtract(Matrix a) and multiplyScalar(double n).
I'm wondering right now how to assign my matrix to a class.
Could anyone help?
This is what I've got.
I'm wondering right now how to assign my matrix to a class.
Could anyone help?
This is what I've got.
Code:
import java.util.Scanner;
public class tenpointtwo {
public static void main(String[] args) {
String input;
Scanner in = new Scanner(System.in);
final int ROWS = 3;
final int COLUMNS = 3;
String[][] myMatx = new String[ROWS][COLUMNS];
for (int r = 0; r < ROWS; r++)
for (int c = 0; c < COLUMNS; c++) {
input = in.next();
myMatx[r][c] = input;
}
}
}