Advertisement
michelksu

Untitled

May 5th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package quadradooco;
  7.  
  8. /**
  9.  *
  10.  * @author Michel
  11.  */
  12.  
  13. import java.util.Scanner;
  14.  
  15. public class QuadradoOco {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         // TODO code application logic here
  22.         Scanner input = new Scanner(System.in);
  23.         System.out.println("Input square length in UNITS");
  24.         int length = input.nextInt();
  25.         if (length < 0) {
  26.             length *= -1;
  27.         }
  28.         int i = 1,
  29.             f = 1;
  30.         while ( i <= length ) {
  31.             f = 1;
  32.             while (f <= length) {
  33.                 if ( i == 1 || i == length || f == length || f == 1 ) {
  34.                     System.out.print("#");
  35.                     f++;
  36.                 }
  37.                 else {
  38.                     System.out.print(" ");
  39.                     f++;
  40.                 }
  41.             }
  42.         System.out.print("\n");
  43.         i++;
  44.         }
  45.     }    
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement