Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Fort {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- System.out.print("/");
- System.out.print(repeatStr("^",n / 2 ));
- System.out.print("\\");
- if (n > 4){
- System.out.print(repeatStr("_", n / 2));}
- System.out.print("/");
- System.out.print(repeatStr("^",n / 2 ));
- System.out.print("\\");
- System.out.println();
- for (int col = 0; col < n - 2; col++){
- System.out.print("|");
- System.out.print(repeatStr(" ", 2 * n - 2));
- System.out.print("|");
- System.out.println();
- }
- System.out.print("\\");
- System.out.print(repeatStr("_", n / 2));
- System.out.print("/");
- if (n > 4){
- System.out.print(repeatStr("-", n / 2));}
- System.out.print("\\");
- System.out.print(repeatStr("_", n / 2));
- System.out.print("/");
- System.out.println();
- }
- static String repeatStr(String strToRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text = text + strToRepeat;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment