borkins

09. House

Apr 5th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. /**
  2.  * Project: Drawing_With_Loops - created by borkins on 2017-04-02.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _09_House
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.         StringBuilder roof = new StringBuilder();
  13.        
  14.         int n = Integer.parseInt(console.nextLine());
  15.        
  16.         roof.append((n % 2 == 0) ? "**" : "*");
  17.    
  18.         for (int row = 0; row < n - n / 2; row++)
  19.         {
  20.             for (int col = 0; col <= n - roof.length(); col++)
  21.             {
  22.                 if (col != (n - roof.length()) / 2) {
  23.                     System.out.print("-");
  24.                 }
  25.                 else {
  26.                     System.out.print(roof);
  27.                 }
  28.             }
  29.             System.out.println();
  30.             roof.append("**");
  31.         }
  32.        
  33.         for (int row = 0; row < n / 2; row++)
  34.         {
  35.             System.out.print("|");
  36.             for (int col = 0; col < n - 2; col++) {
  37.                 System.out.print("*");
  38.             }
  39.             System.out.println("|");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment