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());
- if (n % 2 == 0) {
- for (int i = 1; i <= n / 2; i++) {
- System.out.print(method("-", ((n / 2) - 1) - i + 1) + method("**", i) + method("-", ((n / 2 - 1)) - i + 1));
- System.out.println();
- }
- for (int i = 1; i <= n/2; i++) {
- System.out.print("|"+method("*",n-2)+"|");
- System.out.println();
- }
- }
- else if (n%2!=0){
- for (int i = 1; i <=(n+1)/2 ; i++) {
- System.out.print(method("-", ((n +1 )/2) - i ) + method("*", i)+method("*",i-1) + method("-", ((n+1)/ 2)-i));
- System.out.println();
- }
- for (int i = 0; i < (n-1)/2; i++) {
- System.out.print("|"+method("*",n-2)+"|");
- System.out.println();
- }
- }
- }
- public static String method(String text, int count) {
- String output = "";
- for (int i = 0; i < count; i++) {
- output = output + text;
- }
- return output;
- }
- }
Add Comment
Please, Sign In to add comment