1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import java.util.Scanner; public class AsciiSquare { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int side = sc.nextInt(); for(int i = 0; i<side; i++) { for(int k = 0; k<side; k++) { if(i == 0 || k = 0 || i == (side-1) || k == (side-1)) System.out.print("*"); } System.out.println(""); } } }
Refactorings
No refactoring yet !
Simply prints a square with the side of user given argument.