Skip to content

Commit

Permalink
Merge pull request #646 from vijayv18/java-programs
Browse files Browse the repository at this point in the history
Java programs
  • Loading branch information
mergify[bot] authored Oct 11, 2023
2 parents 7c0f09b + d5695f1 commit 4b7522c
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern1 {
public class StarPattern01 {
public static void main(String[] args) {
for(int i=1;i<=5;i++) {
for(int j=1;j<=i;j++) {
Expand All @@ -8,3 +8,17 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
**
***
****
*****
*/


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern2 {
public class StarPattern02 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
Expand All @@ -8,4 +8,16 @@ public static void main(String[] args) {
System.out.println();
}
}
}
}

/*
The output for the above program.
*****
****
***
**
*
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern3 {
public class StarPattern03 {

public static void main(String[] args) {
for(int i=1;i<=5;i++)
Expand All @@ -15,4 +15,19 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
**
***
****
*****
*/



Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern4 {
public class StarPattern04 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
Expand All @@ -14,3 +14,15 @@ public static void main(String[] args) {
}

}

/*
The output for the above program.
*****
****
***
**
*
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern5 {
public class StarPattern05 {

public static void main(String[] args) {

Expand All @@ -24,3 +24,18 @@ public static void main(String[] args) {

}
}

/*
The output for the above program.
*****
****
***
**
*
The difference between StarPattern4 and StarPattern5 is the beginning white
space in the first line that StarPattern4 holds which StarPattern5 avoids.
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern6 {
public class StarPattern06 {

public static void main(String[] args) {
for(int i=1;i<=5;i++)
Expand All @@ -15,3 +15,15 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
* *
* * *
* * * *
* * * * *
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern7 {
public class StarPattern07 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
Expand All @@ -15,3 +15,15 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
***
*****
*******
*********
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern8 {
public class StarPattern08 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
Expand All @@ -12,3 +12,15 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*********
*******
*****
***
*
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StarPattern9 {
public class StarPattern09 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
Expand All @@ -15,3 +15,15 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
*
*
*
*
*/
12 changes: 12 additions & 0 deletions Java/Star Patterns/StarPattern10.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ public static void main(String[] args) {
}
}
}

/*
The output for the above program.
*
*
*
*
*
*/
32 changes: 32 additions & 0 deletions Java/Star Patterns/StarPattern11.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
public class StarPattern11 {
public static void main(String[] args) {
for(int i=1;i<=5;i++) {
for(int j=5;j>=i;j--) {
System.out.print(" ");
}
for(int k=1;k<(i*2);k++) {
if(k>1 && k<(i*2)-1)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
}
}
}

/*
The output for the above program.
*
* *
* *
* *
* *
*/




29 changes: 29 additions & 0 deletions Java/Star Patterns/StarPattern12.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class StarPattern12 {

public static void main(String[] args) {
for(int i=5;i>=1;i--) {
for(int j=5;j>=i;j--) {
System.out.print(" ");
}
for(int k=1;k<(i*2);k++) {
if(k>1 && k<(i*2)-1)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
}
}
}

/*
The output for the above program.
* *
* *
* *
* *
*
*/
28 changes: 28 additions & 0 deletions Java/Star Patterns/StarPattern13.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class StarPattern13 {

public static void main(String[] args) {
for(int i=1;i<=5;i++) {
for(int j=1;j<=5;j++) {
if (i>1 && i<5 && j>1 && j<5)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
}

}

}

/*
The output for the above program.
*****
* *
* *
* *
*****
*/
26 changes: 26 additions & 0 deletions Java/Star Patterns/StarPattern14.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class StarPattern14 {

public static void main(String[] args) {
for(int i=0;i<5;i++) {
for(int j=0;j<5;j++) {
if(i==j || i+j==5-1)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}

/*
The output for the above program.
* *
* *
*
* *
* *
*/
Loading

0 comments on commit 4b7522c

Please sign in to comment.