Advertisement
kuruku

NewHouse

May 19th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package _03_SoftUni;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class NewHouse {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner inputScanner = new Scanner(System.in);
  9.         int n = inputScanner.nextInt();
  10.  
  11.         int outerDots = n / 2;
  12.         int innerDots = 1;
  13.  
  14.         for (int i = 0; i < n / 2 + 1; i++) {
  15.             print(outerDots, '-');
  16.             print(innerDots, '*');
  17.             print(outerDots, '-');
  18.             innerDots += 2;
  19.             outerDots--;
  20.             System.out.println();
  21.         }
  22.  
  23.         for (int i = 0; i < n; i++) {
  24.             System.out.print("|");
  25.             print(n-2, '*');
  26.             System.out.println("|");
  27.         }
  28.  
  29.     }
  30.  
  31.     public static void print(int n, char ch) {
  32.         for (int j = 0; j < n; j++) {
  33.             System.out.print(ch);
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement