11). Write a program that generate 6*6 two-dimensional matrix, filled with 0’s and 1’s , display the matrix, check every raw and column have an odd number of 1’s. class Program_11 { public static void main(String[] args) { // creating a 6X6 matrix int[][] matrix = new int[6][6]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { matrix[i][j] = (int) (Math.random() * 2); System.out.print(matrix[i][j] + " "); } System.out.println(); } // Display whether every row and columns have odd number of 1s System.out.println("Envery row" + (isRowsOdd1s(matrix) ? " " : " does not " + "have an odd number of 1s")); System.out.println("Envery row" + (isColumnOdd1s(matrix) ? " " : " does not " + "have an odd number of 1s")); }
Comments