-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix.java
46 lines (31 loc) · 995 Bytes
/
Matrix.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.*;
public class Matrix
{
int numRows;
int numCol;
int[][] matrix;
public Matrix(int numRow, int numCol){
this.numRows = numRow;
this.numCol = numCol;
matrix = new int[numRows][numCol];
Scanner console = new Scanner(System.in);
for(int i = 0;i < numRow;i++){
for(int j = 0;j < numCol;j++){
System.out.println("What value for row " + i + " column " + j);
int val = console.nextInt();
matrix[i][j] = val;
//System.out.println(matrix[i][j]);
}
System.out.println();
}
}
public int getVal(int row, int col){
return matrix[row][col];
}
public int getRows(){
return numRows;
}
public int getCol(){
return numCol;
}
}