Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class p88_Sunglasess {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7.  
  8. String stars = repeatStr("*",n * 2 );
  9. String space = repeatStr(" ",n);
  10. System.out.println(stars + space + stars);
  11. for (int i = 0; i < n - 2 ; i++) {
  12. String slash = repeatStr("/", n * 2 - 2);
  13. String pipes = repeatStr("|", n);
  14. //METOD S TERNAREN OPERATOR
  15. System.out.print("*" + slash + "*");
  16. System.out.print(i == (n - 1) / 2 - 1 ? pipes:space);
  17. System.out.println("*" + slash + "*");
  18. }
  19. System.out.println(stars + space + stars);
  20. }
  21. static String repeatStr(String strToRepeat, int count) {
  22. String text = "";
  23. for (int i = 0; i < count; i++) {
  24. text += strToRepeat;
  25. }
  26. return text;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement