Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Crown {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- //FirstPart
- int space = n - 2;
- System.out.printf("@%s@%s@%n",
- repeatStr(" ", space),
- repeatStr(" ", space));
- //SecondPart
- space--;
- System.out.printf("**%s*%s**%n",
- repeatStr(" ", space),
- repeatStr(" ", space));
- //ThirdPart
- int end = (n / 2 - 1) - 1;
- space -= 2;
- int midPonits = 1;
- int leftPoints = 1;
- for (int row = 1; row <= end; row++) {
- System.out.printf("*%s*%s*%s*%s*%s*%n",
- repeatStr(".", leftPoints),
- repeatStr(" ", space),
- repeatStr(".", midPonits),
- repeatStr(" ", space),
- repeatStr(".", leftPoints));
- midPonits += 2;
- leftPoints++;
- space -= 2;
- }
- //FourthPart
- System.out.printf("*%s*%s*%s*%n",
- repeatStr(".", leftPoints),
- repeatStr(".", midPonits),
- repeatStr(".", leftPoints));
- midPonits = (midPonits - 1) / 2;
- leftPoints++;
- //FifthPart
- System.out.printf("*%s%s.%s%s*%n",
- repeatStr(".", leftPoints),
- repeatStr("*", midPonits),
- repeatStr("*", midPonits),
- repeatStr(".", leftPoints));
- int weigt = (2 * n) - 1;
- //LastPart
- for (int i = 0; i < 2; i++) {
- System.out.printf("%s%n", repeatStr("*", weigt));
- }
- }
- static String repeatStr(String strToRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text = text + strToRepeat;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement