-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update readme and add pattern programming
- Loading branch information
Ankush Raj Mahe Yam
committed
Dec 9, 2024
1 parent
5a8b2dd
commit 6a4a377
Showing
16 changed files
with
705 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
*/ | ||
|
||
import java.util.Scanner; | ||
class Q1 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
System.out.println("*"); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
|
||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q1.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* * * * * | ||
* * * * * | ||
* * * * | ||
* * * * * | ||
* * * * * | ||
*/ | ||
import java.util.Scanner; | ||
public class Q10 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n; j++){ | ||
if(i<=2 || j<=2 || i>=n-1 || j>=n-1){ | ||
System.out.printf("* "); | ||
} | ||
else{ | ||
System.out.printf(" "); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
sc.close(); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q8.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* * * * * | ||
* * * | ||
* * * * * | ||
* * * | ||
* * * * * | ||
*/ | ||
import java.util.Scanner; | ||
public class Q11 { | ||
public static void pattern(int n){ | ||
int mid = n/2+1; | ||
if(n%2==0){ | ||
System.out.println("it is only give perfect structure in odd number. So, Please Enter a odd number."); | ||
return; | ||
} | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n; j++){ | ||
if(i==mid || j==mid || i==1 || j==1 || i==n || j==n){ | ||
System.out.printf("* "); | ||
} | ||
else{ | ||
System.out.printf(" "); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
sc.close(); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q11.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* * * * * | ||
* * * * | ||
* * * | ||
* * * * | ||
* * * * * | ||
*/ | ||
import java.util.Scanner; | ||
public class Q12 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n; j++){ | ||
if(i==1 || j==1 || i==n || j==n || i==j || i+j==n+1){ | ||
System.out.printf("* "); | ||
} | ||
else{ | ||
System.out.printf(" "); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
sc.close(); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q12.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* * * * | ||
* * | ||
* * * * * | ||
* * | ||
* * * * | ||
*/ | ||
import java.util.Scanner; | ||
public class Q13 { | ||
public static void pattern(int n){ | ||
int mid = n/2+1; | ||
if(n%2==0){ | ||
System.out.println("Please enter odd number for get proper pattern."); | ||
return; | ||
} | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n; j++){ | ||
if(i==mid || j==mid || i==1 && j>=mid || j==1 && i<=mid || i==n && j<=mid || j==n && i>=mid){ | ||
System.out.printf("* "); | ||
} | ||
else{ | ||
System.out.printf(" "); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
sc.close(); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q13.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* * * * * * * | ||
*/ | ||
import java.util.Scanner; | ||
public class Q2 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
System.out.print("* "); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
|
||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q2.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* * * * * * * | ||
* * * * * * * | ||
* * * * * * * | ||
* * * * * * * | ||
* * * * * * * | ||
*/ | ||
|
||
import java.util.Scanner; | ||
|
||
public class Q3 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n; j++){ | ||
System.out.print("* "); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
Scanner sc = new Scanner(System.in); | ||
|
||
System.out.print("Enter a number : "); | ||
int n = sc.nextInt(); | ||
|
||
pattern(n); | ||
sc.close(); | ||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q3.java | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* * * | ||
* * * | ||
* * * | ||
* * * | ||
* * * | ||
*/ | ||
|
||
public class Q4 { | ||
public static void pattern(int n){ | ||
for(int i = 1; i<=n; i++){ | ||
for(int j=1; j<=n-4; j++){ | ||
System.out.print("* "); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String [] args){ | ||
int n = 7; | ||
|
||
pattern(n); | ||
|
||
} | ||
} | ||
|
||
/* | ||
More Pattern Based Questions uploaded in this folder link :- | ||
https://github.com/AnkushRajMaheYam/Java-Assignment_J-Spider/tree/main/Assign24 | ||
// Folder Structure :- | ||
Java-Assignment_J-Spider/ | ||
├── Assign24/ | ||
└── Q4.java | ||
*/ |
Oops, something went wrong.