AlexKondov

Java New House

May 20th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class NewHouse {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.         int n = input.nextInt();
  9.         int symbolsBefore = (n - 1) / 2;
  10.         int roof = 1;
  11.        
  12.         for (int i = 0; i < (n / 2) + 1; i++) {
  13.             String dashes = new String(new char[symbolsBefore]).replace("\0", "-");
  14.             String stars = new String(new char[roof]).replace("\0", "*");
  15.             String dots = new String(new char[symbolsBefore]).replace("\0", "-");
  16.             System.out.printf("%s%s%s", dashes, stars, dashes);
  17.             System.out.println();
  18.             symbolsBefore --;
  19.             roof += 2;
  20.         }
  21.        
  22.         for (int i = 0; i < n; i++) {
  23.             System.out.print('|');
  24.             String dots = new String(new char[n - 2]).replace("\0", "*");
  25.             System.out.print(dots);
  26.             System.out.println('|');
  27.         }
  28.        
  29.         input.close();
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment