borkins

05. Square Frame

Apr 5th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. /**
  2.  * Project: Drawing_With_Loops - created by borkins on 2017-04-01.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _05_SquareFrame
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int n = Integer.parseInt(console.nextLine());
  14.        
  15.         for (int row = 0; row < n; row++)
  16.         {
  17.             String frame = (row > 0 && row < n - 1) ? "|" : "+";
  18.    
  19.             System.out.print(frame + " ");
  20.            
  21.             for (int col = 0; col < n - 2; col++) {
  22.                 System.out.print("- ");
  23.             }
  24.             System.out.println(frame);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment