Write a program in Java to create a matrix a[][] of order (m × n).

Here, ‘m’ is the number of rows and ‘n’ is the number of columns.

Note that the values of both ‘m’ and ‘n’ must be greater than 2 and less than 10.

Now fill each row of the matrix uniformly by 1 or 0 alternately.

Sample Input:

M=3

N=3

Resultant matrix:

1 1 1

0 0 0

1 1 1

```
import java.io.*;
class Alternate{
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("m: ");
int m = Integer.parseInt(br.readLine());
System.out.print("Columns: ");
int n = Integer.parseInt(br.readLine());
if(m < 3 || n < 3 || m > 9 || n > 9){
System.out.println("Invalid range!");
return;
}
int a[][] = new int[m][n];
int value = 1;
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
a[i][j] = value;
}
if(value == 1)
value = 0;
else
value = 1;
}
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
System.out.print(a[i][j] + "\t");
}
System.out.println();
}
}
}
```