Advertisement
xboy90

java

Feb 19th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package CodeAcademy_5_Loops_And_Arrays;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DrawSquareDemo
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner scanner = new Scanner(System.in);
  10. System.out.println("Enter n: ");
  11. int n = scanner.nextInt();
  12.  
  13.  
  14. while (!(n > 0 && n <= 30)) {
  15. System.out.println("N, not in range, it should be (0,30]: ");
  16. n = scanner.nextInt();
  17. }
  18.  
  19. int[][] arr = new int[n][n];
  20.  
  21. for (int col = 0; col < n; col++) {
  22. for (int row = 0; row < n; row++) {
  23. System.out.print("# ");
  24. }
  25. System.out.println();
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement