Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class suns {
- public static void main (String [] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int stars = 0;
- if(n % 2 == 0) {
- stars = 2;
- }else{
- stars = 1;
- }
- for (int i = 0; i < Math.ceil(n / 2.0) ; i++) {
- String row =
- repeatStr("_",(n - stars) / 2 )
- + repeatStr("*",stars)
- +repeatStr("_",(n - stars) / 2);
- stars += 2;
- System.out.println(row);
- }
- for (int i = 0; i < n / 2; i++) {
- String row = "|" + repeatStr("*",n-2) + "|";
- System.out.println(row);
- }
- }
- static String repeatStr(String strToRepeat, int count ) {
- String text = "";
- for (int i = 0; i < count ; i++) {
- text = text + strToRepeat;
- }
- return strToRepeat;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement