-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise2117.java
More file actions
41 lines (33 loc) · 957 Bytes
/
Copy pathExercise2117.java
File metadata and controls
41 lines (33 loc) · 957 Bytes
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
import java.util.Scanner;
public class Exercise2117
{
public static boolean[][] readBoolean2D()
{
Scanner input = new Scanner(System.in);
// Getting Int input
System.out.print("Enter nr of rows: ");
int myRows = input.nextInt();
System.out.println("rows entered = " + myRows);
System.out.print("Enter nr of columns: ");
int myColumns = input.nextInt();
System.out.println("columns entered = " + myColumns);
int M = myRows;
int N = myColumns;
boolean[][] a = new boolean[M][N];
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
System.out.print("Enter item in row " + i + " and column " + j + ": " );
a[i][j] = input.nextBoolean();
}
}
input.close();
return a;
}
public static void main(String[] args)
{
boolean[][] callmethod = readBoolean2D();
System.out.println(java.util.Arrays.deepToString(callmethod));
}
}