Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import com.sun.org.apache.xpath.internal.SourceTree;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int purvitretired=n*2;
- int vtorired=n*2;
- System.out.printf(repeatStr("*",purvitretired));
- System.out.printf(repeatStr(" ",n));
- System.out.println(repeatStr("*",purvitretired));
- for (int i = 0; i <n-2 ; i++) {
- System.out.printf("*");
- System.out.printf(repeatStr("/",purvitretired-2));
- System.out.printf("*");
- if (n%2==1) {
- if (i + 1 == n / 2) {
- System.out.printf(repeatStr("|", n));
- }
- }
- if (n%2==1) {
- if (i + 1 != n / 2) {
- System.out.printf(repeatStr(" ", n));
- }
- }
- if(n%2==0){
- if(i!=n/2-2){
- System.out.printf(repeatStr(" ",n));
- }
- }
- if (n%2==0){
- if (i==n/2-2){
- System.out.printf(repeatStr("|",n));
- }
- }
- System.out.printf("*");
- System.out.printf(repeatStr("/",purvitretired-2));
- System.out.println("*");
- }
- System.out.printf(repeatStr("*",purvitretired));
- System.out.printf(repeatStr(" ",n));
- System.out.println(repeatStr("*",purvitretired));
- }
- static String repeatStr(String text,int countToRepeat){
- StringBuilder result=new StringBuilder();
- for (int i = 0; i <countToRepeat ; i++) {
- result.append(text);
- }
- return result.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement