Last active
June 9, 2020 08:52
-
-
Save gebes/9867fdea9815c9c0e2434789a53eede1 to your computer and use it in GitHub Desktop.
Simple solution to the Square Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.microsoft; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
int size = new Scanner(System.in).nextInt(); | |
for (int i = 0; i < size; i++) { | |
for (int j = 0; j < size; j++) | |
System.out.print(isOnBorder(i, j, size) ? "*" : " "); | |
System.out.println(); | |
} | |
} | |
private static boolean isOnBorder(int x, int y, int size) { | |
return (x == 0 || y == 0 || x == size - 1 || y == size - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment