Skip to content

Commit

Permalink
patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshgaigawali committed Aug 1, 2024
1 parent 8444f8c commit e124498
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
29 changes: 29 additions & 0 deletions problems/Pattern01.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*Print the following pattern: Solid Rectangle
* * * * *
* * * * *
* * * * *
* * * * *
*/

package problems;

class Pattern01 {

public static void main(String args[]) {

int rows = 4;
int columns = 5;

for (int i = 1; i <= rows; i++) {

for (int j = 1; j <= columns; j++) {
System.out.print("* ");
}
System.out.println();
}

}

}
30 changes: 30 additions & 0 deletions problems/Pattern02.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*Print the following pattern: Hollow Rectangle
* * * * *
* *
* *
* * * * *
*/

package problems;

public class Pattern02 {

public static void main(String[] args) {
int rows = 4;
int columns = 5;

for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= columns; j++) {
if (i == 1 || j == 1 || i == rows || j == columns) {
System.out.print("* ");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}

}
30 changes: 30 additions & 0 deletions problems/Pattern03.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*Print the following pattern: Hollow Rectangle
*
* *
* * *
* * * *
*/

package problems;

public class Pattern03 {

public static void main(String[] args) {
int rows = 4;
int columns = 4;

for (int i = 1; i <= rows; i++) {

for (int j = 1; j <= i; j++) {

System.out.print("* ");

}

System.out.println();
}
}

}

0 comments on commit e124498

Please sign in to comment.