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