Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CodeAcademy_5_Loops_And_Arrays;
- import java.util.Scanner;
- public class DrawSquareDemo
- {
- public static void main(String[] args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter n: ");
- int n = scanner.nextInt();
- while (!(n > 0 && n <= 30)) {
- System.out.println("N, not in range, it should be (0,30]: ");
- n = scanner.nextInt();
- }
- int[][] arr = new int[n][n];
- for (int col = 0; col < n; col++) {
- for (int row = 0; row < n; row++) {
- System.out.print("# ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement