ralitsa_d

Stop

Feb 4th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Stop {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scan.nextLine());
  8.  
  9. int width = n * 5 - (n - 3);
  10. int leftRight = n + 1;
  11. int middle = width - leftRight * 2;
  12.  
  13. System.out.printf("%s%s%s\n",
  14. repeatChar(leftRight, '.'),
  15. repeatChar(middle, '_'),
  16. repeatChar(leftRight, '.'));
  17.  
  18. middle -= 2;
  19. for (int i = 0; i < n; i++) {
  20. leftRight--;
  21.  
  22. System.out.printf("%s//%s\\\\%s\n",
  23. repeatChar(leftRight, '.'),
  24. repeatChar(middle, '_'),
  25. repeatChar(leftRight, '.'));
  26.  
  27. middle += 2;
  28. }
  29.  
  30. int inside = (middle - 5) / 2;
  31.  
  32. System.out.printf("//%sSTOP!%s\\\\\n",
  33. repeatChar(inside, '_'),
  34. repeatChar(inside, '_')
  35. );
  36.  
  37. leftRight = 0;
  38.  
  39. for (int i = 0; i < n; i++) {
  40. System.out.printf("%s\\\\%s//%s\n",
  41. repeatChar(leftRight, '.'),
  42. repeatChar(middle, '_'),
  43. repeatChar(leftRight, '.'));
  44. leftRight++;
  45. middle -= 2;
  46. }
  47. }
  48.  
  49. private static String repeatChar(int n, char ch){
  50. StringBuilder sb = new StringBuilder();
  51.  
  52. for (int i = 0; i < n; i++) {
  53. sb.append(ch);
  54. }
  55.  
  56. return sb.toString();
  57. }
  58. }
Add Comment
Please, Sign In to add comment