Advertisement
Dimitar_Iliev

Butterfly

Jan 12th, 2020
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Butterfly {
  4.    
  5.      public static void main(String[] args) {
  6.          
  7.             Scanner scan = new Scanner(System.in);
  8.      
  9.             int n = Integer.parseInt(scan.nextLine());
  10.      
  11.             for (int row = 0; row < n - 2; row++) {
  12.               if(row % 2 == 0){
  13.                 System.out.print(repeatStr("*", n - 2));
  14.                 System.out.print("\\");
  15.                 System.out.print(" ");
  16.                 System.out.print("/");
  17.                 System.out.println(repeatStr("*", n - 2));
  18.               }else {
  19.                 System.out.print(repeatStr("-", n - 2));
  20.                 System.out.print("\\");
  21.                 System.out.print(" ");
  22.                 System.out.print("/");
  23.                 System.out.println(repeatStr("-", n - 2));
  24.               }
  25.             }
  26.      
  27.             System.out.print(repeatStr(" ", n-1));
  28.             System.out.println("@");
  29.      
  30.             for (int row = 0; row < n - 2; row++){
  31.               if(row % 2 == 0){
  32.                 System.out.print(repeatStr("*", n - 2));
  33.                 System.out.print("/");
  34.                 System.out.print(" ");
  35.                 System.out.print("\\");
  36.                 System.out.println(repeatStr("*", n -2));
  37.               }else {
  38.                 System.out.print(repeatStr("-", n - 2));
  39.                 System.out.print("/");
  40.                 System.out.print(" ");
  41.                 System.out.print("\\");
  42.                 System.out.println(repeatStr("-", n - 2));
  43.               }
  44.             }
  45.         }
  46.         static String repeatStr(String strToRepeat, int count) {
  47.             String text = "";
  48.      
  49.             for (int i = 0; i < count; i++) {
  50.                 text = text + strToRepeat;
  51.             }
  52.      
  53.             return text;
  54.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement