Skip to content

Commit

Permalink
Create StarPrinting.java
Browse files Browse the repository at this point in the history
This is my first try for contributing in opensource
  • Loading branch information
Aryan-Bhendarkar authored and x0lg0n committed Oct 29, 2024
1 parent 9ba1c5e commit 85d5341
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Java/StarPrinting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.util.*;
public class star {
public static void main(String[] args) {
Scanner scn = new Scanner (System.in);
int N = scn.nextInt();

//upperstar
for(int i = 1 ; i<=N ; i++){
for(int j = 1; j<=2*N-i ; j++){
System.out.print(" ");
}
for(int k = 0 ; k<2*i-1 ; k++){
System.out.print("*");
}
System.out.println();
}

//upper2
for(int i = 0 ; i < N ; i++){
for(int a = 0 ; a<i ; a++){
System.out.print(" ");
}
for(int b = 1 ; b<4*N-2*i; b++){
System.out.print("*");
}
System.out.println();
}

//upper3
for(int i = 1 ; i <= N ; i++){
for(int a = 0 ; a<N-i ; a++){
System.out.print(" ");
}
for(int b = 1 ; b<2*N+2*i; b++){
System.out.print("*");
}
System.out.println();
}

//bottom
for(int i = 0 ; i< N ; i++){
for(int j = 1 ; j<=N+i ; j++){
System.out.print(" ");
}
for(int k = 1; k<2*(N-i); k++){
System.out.print("*");
}
System.out.println();
}
scn.close();
}

}

0 comments on commit 85d5341

Please sign in to comment.