Matrix Class (starting code)

 

public class Matrix {


public static void main(String[] args) {

// create a 2 X 2 matrix


Scanner input = new Scanner(System.in);

// create two arrays

int [][] array1 = new int[2][2];


int choice = 0;

System.out.println("Welcome to the Matrix Calculator");

for (int i =0; i<array1.length; i++) {

for (int j =0; j<array1[i].length; j++) {

System.out.println("i = " + i);

System.out.println("j = " + j);

System.out.println("array1[i].length = " +array1[i].length);

System.out.println("Please enter a value for the first matrix");

array1 [i][j] = input.nextInt();

} // end of inner for loop

} // end of outer for loop

// Print out the array in matrix form

for (int i =0; i<array1.length; i++) {

System.out.println();

for (int j =0; j<array1[i].length; j++) {

System.out.print(array1 [i][j] + " ");

} // end of inner for loop

} // end of outer for loop

input.close();

}

}