Nackey

Exam - 24 April 2016 problem 05 - STOP

Aug 10th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class STOP {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(sc.nextLine());
  8.         int points = n+1;
  9.         int width = (n+1)*4+1;
  10.         int line = width/2+1;
  11.         System.out.println(repeatString(".",points)+repeatString("_",line)+repeatString(".",points));
  12.  
  13.         int line2 = width-n*2-4;
  14.         for (int i = 1; i <= n; i++){
  15.             points--;
  16.             System.out.print(repeatString(".",points)+"//");
  17.             System.out.println(repeatString("_",line2)+"\\\\"+repeatString(".",points));
  18.             line2+=2;
  19.         }
  20.         System.out.println("//"+repeatString("_",(width-9)/2)+"STOP!"+repeatString("_",(width-9)/2)+"\\\\");
  21.         System.out.println("\\\\"+repeatString("_",width-4)+"//");
  22.  
  23.         int point2 = 1;
  24.         int line3 = width-6;
  25.         for (int i = 1; i<n; i++){
  26.             System.out.println(repeatString(".",point2)+"\\\\"+repeatString("_",line3)+"//"+repeatString(".",point2));
  27.             point2++;
  28.             line3-=2;
  29.         }
  30.     }
  31.     static String repeatString (String toRepeat, int count){
  32.         String text = "";
  33.  
  34.         for (int i = 1; i <= count; i++){
  35.             text = text + toRepeat;
  36.         }
  37.         return text;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment