Advertisement
tchenkov

L06u09_House

Feb 16th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 15.02.2017 г..
  7.  */
  8. public class u09_House {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int houseHeight = Integer.parseInt(scan.nextLine());
  12.         int houseRoofHeight = houseHeight/2 + houseHeight % 2;
  13.         int houseWallHeight = houseHeight/2;
  14.        
  15.         for (int i = 1; i <= houseRoofHeight; i++) {
  16.             int dashesCount = houseRoofHeight - i;
  17.             String dashes = stringRepeater("-", dashesCount);
  18.             int starsCount = houseHeight - dashesCount*2;
  19.             String stars = stringRepeater("*", starsCount);
  20.             System.out.println(dashes + stars + dashes);
  21.         }
  22.        
  23.         String houseBody = "|" + stringRepeater("*", houseHeight-2) + "|";
  24.         for (int i = 0; i < houseWallHeight; i++) {
  25.             System.out.println(houseBody);
  26.         }
  27.     }
  28.    
  29.     static String stringRepeater (String stringToRepeat, int stringRepeatCount){
  30.         String outputString = "";
  31.         for (int i = 0; i < stringRepeatCount; i++) {
  32.             outputString += stringToRepeat;
  33.         }
  34.         return outputString;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement