Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Stop {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int width = n * 5 - (n - 3);
- int leftRight = n + 1;
- int middle = width - leftRight * 2;
- System.out.printf("%s%s%s\n",
- repeatChar(leftRight, '.'),
- repeatChar(middle, '_'),
- repeatChar(leftRight, '.'));
- middle -= 2;
- for (int i = 0; i < n; i++) {
- leftRight--;
- System.out.printf("%s//%s\\\\%s\n",
- repeatChar(leftRight, '.'),
- repeatChar(middle, '_'),
- repeatChar(leftRight, '.'));
- middle += 2;
- }
- int inside = (middle - 5) / 2;
- System.out.printf("//%sSTOP!%s\\\\\n",
- repeatChar(inside, '_'),
- repeatChar(inside, '_')
- );
- leftRight = 0;
- for (int i = 0; i < n; i++) {
- System.out.printf("%s\\\\%s//%s\n",
- repeatChar(leftRight, '.'),
- repeatChar(middle, '_'),
- repeatChar(leftRight, '.'));
- leftRight++;
- middle -= 2;
- }
- }
- private static String repeatChar(int n, char ch){
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < n; i++) {
- sb.append(ch);
- }
- return sb.toString();
- }
- }
Add Comment
Please, Sign In to add comment