Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DrawingFiguresWithLoops;
- import java.util.Scanner;
- public class FortProblem2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int width = 2*n;
- int height = n;
- // TOP LANE
- String horns =repeatStr("^", n/2) ;
- String slash =repeatStr( "_" ,width -( 2*(n/2)) - 4);
- System.out.println("/" + horns +"\\" +slash + "/" +horns + "\\");
- // Middle
- String spacesBetwenWalls = repeatStr(" ", width-2);
- for (int i = 1; i <=n-3 ; i++) {
- System.out.println("|" + spacesBetwenWalls+"|");
- }
- // Before Ground
- String spacesBeforeGround = repeatStr(" ",n/2+1);
- System.out.println( "|"+ spacesBeforeGround +slash + spacesBeforeGround+"|" );
- // Ground Level
- String ground = repeatStr("_",n/2);
- String spacesOnGround = repeatStr(" ",width -( 2*(n/2)) - 4);
- System.out.println("\\"+ground + "/"+spacesOnGround+"\\"+ground+"/");
- }
- static String repeatStr(String str, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text += str;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement