Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class House {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- int stars = 0;
- if (n % 2 == 0) {
- stars = 2;
- } else {
- stars = 1;
- }
- int lines = (n - stars) / 2;
- //top
- for (int i = 0; i < lines; i++) {
- System.out.print("-");
- }
- for (int i = 0; i < stars; i++) {
- System.out.print("*");
- }
- for (int i = 0; i < lines; i++) {
- System.out.print("-");
- }
- System.out.println();
- //center
- for (int i = 1; i < (n + 1) / 2; i++) {
- stars = stars + 2;
- lines = lines - 1;
- //left lines
- for (int j = 0; j < lines; j++) {
- System.out.print("-");
- }
- for (int j = 0; j < stars; j++) {
- System.out.print("*");
- }
- //right lines
- for (int j = 0; j < lines; j++) {
- System.out.print("-");
- }
- System.out.println();
- }
- //bottom
- for (int i = 0; i <= n / 2 - 1; i++) {
- System.out.print("|");
- for (int j = 0; j < n - 2; j++) {
- System.out.print("*");
- }
- System.out.print("|");
- System.out.println();
- }
- }
- private static String repeat(String string, int count) {
- String output = "";
- for (int i = 0; i < count; i++) {
- output += string;
- }
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement