Created
July 1, 2021 18:08
-
-
Save bijay-shrestha/5252c36042b4374789d110c87b0280b5 to your computer and use it in GitHub Desktop.
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
/** | |
* | |
* Print Nepal Flag in your console. | |
*/ | |
package com.basic.practice; | |
public class NepalFlag { | |
public static void main(String[] args) { | |
printFlag(); | |
printFlag(); | |
} | |
static void printFlag() { | |
for (int i = 0; i < 5; i++) { | |
for (int j = 0; j <= i; j++) { | |
System.out.print("*"); | |
} | |
System.out.println(); | |
} | |
} | |
} |
static void printNepalFlag() {
int col = 5;
for (int i = 0; i <= col; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || i == j || i == col) {
System.out.print(" * ");
} else {
System.out.print(" ");
}
}
System.out.println("");
}
}
/* *
* *
* *
* *
* *
* * * * * *
*
* *
* *
* *
* *
* * * * * *
* */
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about only outer layer of flag?