Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DrawingWithLoop;
- import java.util.Scanner;
- public class Stop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int width = 4 * n + 3;
- String firstLine = repeatString(".", n + 1)
- + repeatString("_", n * 2 + 1)
- + repeatString(".", n + 1);
- System.out.println(firstLine);
- for (int i = 0; i < n + 1; i++) {
- String line = repeatString(".", n - i)
- + "//"
- + repeatString("_", (n * 2 - 1) + 2 * i)
- + "\\\\"
- + repeatString(".", n - i);
- if (i == n) {
- line = repeatString(".", n - i)
- + "//"
- + repeatString("_", (width - 9) / 2)
- + "STOP!"
- + repeatString("_", (width - 9) / 2)
- + "\\\\"
- + repeatString(".", n - i);
- }
- System.out.println(line);
- }
- for (int i = 0; i < n; i++) {
- String line = repeatString(".", i)
- + "\\\\"
- + repeatString("_",(4 * n) - 1 - (2 * i))
- + "//"
- + repeatString(".", i);
- System.out.println(line);
- }
- }
- public static String repeatString(String toRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text += toRepeat;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment