Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SnowFlake {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n - 1; i++) {
- String firstAndLastLines = repeatStr(".", i)
- + "*"
- + repeatStr(".", n - i)
- + "*"
- + repeatStr(".", n - i)
- + "*"
- + repeatStr(".", i);
- System.out.println(firstAndLastLines);
- }
- String middleLines = repeatStr(".", ((2 * n + 3) - 5) / 2)
- + repeatStr("*", 5)
- + repeatStr(".", ((2 * n + 3) - 5) / 2);
- System.out.println(middleLines);
- String staticLine = repeatStr("*", 2 * n + 3);
- System.out.println(staticLine);
- System.out.println(middleLines);
- for (int i = 1; i <= n - 1; i++) {
- String firstAndLastLine2 = repeatStr(".", n - 1 - i)
- + "*"
- + repeatStr(".", 1 + i)
- + "*"
- + repeatStr(".", 1 + i)
- + "*"
- + repeatStr(".", n - 1 - i);
- System.out.println(firstAndLastLine2);
- }
- }
- static String repeatStr(String strToRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text += strToRepeat;
- }
- return text;
- }
- }
Add Comment
Please, Sign In to add comment