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 1.84 KB | None | 0 0
  1. package com.company;
  2. import com.sun.org.apache.xpath.internal.SourceTree;
  3.  
  4. import java.util.Scanner;
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner scanner = new Scanner(System.in);
  10. int n = Integer.parseInt(scanner.nextLine());
  11. int purvitretired=n*2;
  12. int vtorired=n*2;
  13. System.out.printf(repeatStr("*",purvitretired));
  14. System.out.printf(repeatStr(" ",n));
  15. System.out.println(repeatStr("*",purvitretired));
  16.  
  17. for (int i = 0; i <n-2 ; i++) {
  18. System.out.printf("*");
  19. System.out.printf(repeatStr("/",purvitretired-2));
  20. System.out.printf("*");
  21. if (n%2==1) {
  22. if (i + 1 == n / 2) {
  23. System.out.printf(repeatStr("|", n));
  24. }
  25. }
  26. if (n%2==1) {
  27. if (i + 1 != n / 2) {
  28. System.out.printf(repeatStr(" ", n));
  29. }
  30. }
  31. if(n%2==0){
  32. if(i!=n/2-2){
  33. System.out.printf(repeatStr(" ",n));
  34. }
  35. }
  36. if (n%2==0){
  37. if (i==n/2-2){
  38. System.out.printf(repeatStr("|",n));
  39. }
  40. }
  41. System.out.printf("*");
  42. System.out.printf(repeatStr("/",purvitretired-2));
  43. System.out.println("*");
  44.  
  45. }
  46. System.out.printf(repeatStr("*",purvitretired));
  47. System.out.printf(repeatStr(" ",n));
  48. System.out.println(repeatStr("*",purvitretired));
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57. static String repeatStr(String text,int countToRepeat){
  58. StringBuilder result=new StringBuilder();
  59. for (int i = 0; i <countToRepeat ; i++) {
  60. result.append(text);
  61. }
  62. return result.toString();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement