Skip to content

Commit

Permalink
pattern-12-Alphabet Star Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
6736-shafi committed Sep 27, 2023
1 parent b3c1f68 commit 95280fb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,28 @@
*
```
11. Sandglass Star Pattern
---
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
---
12 Sandglass Star Pattern
```
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
```
13.Alphabet Star Pattern
```
****
* *
* *
* *
*****
* *
* *
* *
* *
```
23 changes: 23 additions & 0 deletions src/AlphabetStarPattern/AlphabetStarPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package AlphabetStarPattern;

public class AlphabetStarPattern {
public static void main(String[] args) {
int i, j, n = 8;
// Outer for loop for number of lines
for (i = 0; i <= n; i++) {
// Inner for loop for logic execution
for (j = 0; j <= n / 2; j++) {
// prints two vertical lines
if ((j == 0 || j == n / 2) && i != 0 ||
// print first line of alphabet
i == 0 && j != n / 2 ||
// prints middle line
i == n / 2)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}

0 comments on commit 95280fb

Please sign in to comment.