Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Sunglasses {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- String FandLRow = repeatStr("*", n * 2)
- + repeatStr(" ", n)
- + repeatStr("*", n * 2);
- System.out.println(FandLRow);
- for (int row = 0; row < n - 2; row++) {
- String MidRow = "*"
- + repeatStr("/", n * 2 - 2)
- + "*";
- if (row == (n - 1) / 2 - 1) {
- MidRow+=repeatStr("|", n);
- } else {
- MidRow+=repeatStr(" ", n);
- }
- MidRow += "*"
- + repeatStr("/", n * 2 - 2)
- + "*";
- System.out.println(MidRow);
- }
- System.out.println(FandLRow);
- }
- 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