In your inner loop you should check whether the number of 1's you have is equal to the entered value. If not, continue changing 0's to 1's, if equal already, don't change the remaining 0's anymore. Read More
try something like this for (int i=0; i<numb.length; i++) { for (int j=0; j<numb[i].length; j++) { if(y != x){ numb[i][j] = 1; y = y +1; } System.out.print(" " + numb[i][j]); } System.out.println(""); } //x - is the input from your user //y - is the tester if the number … Read More