From 6c5ba3eae1b270291dd9e4c9dac45029a9003b7b Mon Sep 17 00:00:00 2001 From: Vijay Date: Fri, 13 Oct 2023 11:07:16 +0530 Subject: [PATCH] add 8 more star pattern java programs --- Java/Star Patterns/StarPattern16.java | 31 ++++++++++++++++ Java/Star Patterns/StarPattern17.java | 50 ++++++++++++++++++++++++++ Java/Star Patterns/StarPattern18.java | 41 +++++++++++++++++++++ Java/Star Patterns/StarPattern19.java | 35 ++++++++++++++++++ Java/Star Patterns/StarPattern20.java | 32 +++++++++++++++++ Java/Star Patterns/StarPattern21.java | 33 +++++++++++++++++ Java/Star Patterns/StarPattern22.java | 52 +++++++++++++++++++++++++++ Java/Star Patterns/StarPattern23.java | 50 ++++++++++++++++++++++++++ 8 files changed, 324 insertions(+) create mode 100644 Java/Star Patterns/StarPattern16.java create mode 100644 Java/Star Patterns/StarPattern17.java create mode 100644 Java/Star Patterns/StarPattern18.java create mode 100644 Java/Star Patterns/StarPattern19.java create mode 100644 Java/Star Patterns/StarPattern20.java create mode 100644 Java/Star Patterns/StarPattern21.java create mode 100644 Java/Star Patterns/StarPattern22.java create mode 100644 Java/Star Patterns/StarPattern23.java diff --git a/Java/Star Patterns/StarPattern16.java b/Java/Star Patterns/StarPattern16.java new file mode 100644 index 00000000..040d5a6d --- /dev/null +++ b/Java/Star Patterns/StarPattern16.java @@ -0,0 +1,31 @@ +public class StarPattern16 { + + public static void main(String[] args) { + int n=5; + for(int i=0;ii;j--) { + System.out.print("* "); + } + for(int space=0;space<=2*i;space++) { + System.out.print(" "); + } + for(int k=n-1;k>i;k--) { + System.out.print("* "); + } + System.out.println(); + } + } + +} + +/* + +The output for the above program. + +* * +* * * * +* * * * * * +* * * * * * * +* * * * * * +* * * * +* * + +*/ + diff --git a/Java/Star Patterns/StarPattern18.java b/Java/Star Patterns/StarPattern18.java new file mode 100644 index 00000000..71b3ab74 --- /dev/null +++ b/Java/Star Patterns/StarPattern18.java @@ -0,0 +1,41 @@ +public class StarPattern18 { + + public static void main(String[] args) { + int n = 4; + for(int i=0;i=i;k--) { + System.out.print(" "); + } + for(int j=0;j<=i;j++) { + System.out.print("* "); + } + System.out.println(); + } + n=n-1; + for(int i=0;i=i;j--) { + System.out.print("* "); + } + System.out.println(); + } + } + +} + +/* + +The output for the above program. + + * + * * + * * * + * * * * + * * * + * * + * + +*/ diff --git a/Java/Star Patterns/StarPattern19.java b/Java/Star Patterns/StarPattern19.java new file mode 100644 index 00000000..52853617 --- /dev/null +++ b/Java/Star Patterns/StarPattern19.java @@ -0,0 +1,35 @@ +public class StarPattern19 { + + public static void main(String[] args) { + int n = 4; + for(int i=0;ii;j--) { + System.out.print("* "); + } + System.out.println(); + } + for(int i=1;i=i;j--) { + System.out.print(" "); + } + for(int k=0;k<=i;k++) { + if(i==0 || i==n-1 || k==0 || k==i) { + System.out.print("* "); + } else { + System.out.print(" "); + } + } + System.out.println(); + } + } + +} + +/* + +The output for the above program. + + * + * * + * * + * * + * * * * * + +*/ diff --git a/Java/Star Patterns/StarPattern21.java b/Java/Star Patterns/StarPattern21.java new file mode 100644 index 00000000..799d9515 --- /dev/null +++ b/Java/Star Patterns/StarPattern21.java @@ -0,0 +1,33 @@ +public class StarPattern21 { + + public static void main(String[] args) { + int n=5; + for(int i=0;i=i;k--) { + if(i==0 || i==n-1 || k==n-1 || k==i) { + System.out.print("* "); + } else { + System.out.print(" "); + } + } + System.out.println(); + } + } + +} + +/* + +The output for the above program. + + * * * * * + * * + * * + * * + * + + +*/ \ No newline at end of file diff --git a/Java/Star Patterns/StarPattern22.java b/Java/Star Patterns/StarPattern22.java new file mode 100644 index 00000000..e53a1dcc --- /dev/null +++ b/Java/Star Patterns/StarPattern22.java @@ -0,0 +1,52 @@ +public class StarPattern22 { + + public static void main(String[] args) { + int n=4; + for(int i=0;i=i;k--) { + if(i==0 || k==n-1 || k==i) { + System.out.print("* "); + } else { + System.out.print(" "); + } + } + System.out.println(); + } + for(int i=1;i=i;j--) { + System.out.print(" "); + } + for(int k=0;k<=i;k++) { + if(k==0 || k==i || i==n-1) { + System.out.print("* "); + } else { + System.out.print(" "); + } + + } + System.out.println(); + } + + } + +} + +/* + +The output for the above program. + + * * * * + * * + * * + * + * * + * * + * * * * + + +*/ + + diff --git a/Java/Star Patterns/StarPattern23.java b/Java/Star Patterns/StarPattern23.java new file mode 100644 index 00000000..2f11f743 --- /dev/null +++ b/Java/Star Patterns/StarPattern23.java @@ -0,0 +1,50 @@ +public class StarPattern23 { + + public static void main(String[] args) { + int n=4; + for(int i=0;i=i;j--) { + System.out.print(" "); + } + for(int k=0;k<=i;k++) { + if(i==0 || k==0 || k==i) { + System.out.print("* "); + } else { + System.out.print(" "); + } + } + System.out.println(); + } + for(int i=1;i=i;k--) { + if(k==n-1 || k==i) { + System.out.print("* "); + } else { + System.out.print(" "); + } + } + System.out.println(); + } + } + +} + +/* + +The output for the above program. + + * + * * + * * + * * + * * + * * + * + + +*/ + +