veronikaaa86

Stop

Feb 20th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package DrawingWithLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Stop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int width = 4 * n + 3;
  12.  
  13.         String firstLine = repeatString(".", n + 1)
  14.                 + repeatString("_", n * 2 + 1)
  15.                 + repeatString(".", n + 1);
  16.         System.out.println(firstLine);
  17.  
  18.         for (int i = 0; i < n + 1; i++) {
  19.             String line = repeatString(".", n - i)
  20.                     + "//"
  21.                     + repeatString("_", (n * 2 - 1) + 2 * i)
  22.                     + "\\\\"
  23.                     + repeatString(".", n - i);
  24.  
  25.             if (i == n) {
  26.                 line = repeatString(".", n - i)
  27.                         + "//"
  28.                         + repeatString("_", (width - 9) / 2)
  29.                         + "STOP!"
  30.                         + repeatString("_", (width - 9) / 2)
  31.                         + "\\\\"
  32.                         + repeatString(".", n - i);
  33.             }
  34.             System.out.println(line);
  35.         }
  36.         for (int i = 0; i < n; i++) {
  37.             String line = repeatString(".", i)
  38.                     + "\\\\"
  39.                     + repeatString("_",(4 * n) - 1 - (2 * i))
  40.                     + "//"
  41.                     + repeatString(".", i);
  42.             System.out.println(line);
  43.         }
  44.     }
  45.  
  46.     public static String repeatString(String toRepeat, int count) {
  47.         String text = "";
  48.         for (int i = 0; i < count; i++) {
  49.             text += toRepeat;
  50.         }
  51.         return text;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment