Skip to content

Pattern #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Patterns/Alpha_row_sqaure.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


import java.util.Scanner;

public class Alpha_pattern {

public static void main(String[] args) {
//ABCD
//ABCD
//ABCD
//ABCD
Scanner s= new Scanner(System.in);
System.out.println("Enter n ");
int n = s.nextInt();
int i=1;
while(i<=n)
{ int j=1;
while(j<=n){

System.out.print((char)('A'+j-1));
j=j+1;
}
System.out.println();
i=i+1;
}

}
}
44 changes: 44 additions & 0 deletions Patterns/Rhombus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Do you want to continue?: y

Enter the no. of rows: 5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
*/
import java.util.Scanner;

public class Rhombus
{
public static void main(String[] args)
{
outer:
while(true)
{
System.out.println();
Scanner a = new Scanner(System.in);
char y;
System.out.print("Enter the no. of rows: ");
int r = a.nextInt();

for(int i=1;i<=r;i++)
{
for(int j=1;j<=r-i;j++)
{
System.out.print(" ");
}
for(int j=1;j<=r;j++)
{
System.out.print("*"+" ");
}
System.out.println();
}
System.out.print("\nDo you want to continue?: ");
y = a.next().charAt(0);
if (y == 'N' || y == 'n')
{
break outer;
} } } }

36 changes: 36 additions & 0 deletions Patterns/Solid_square_pattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Enter Number
4
****
****
****
****

*/

import java.util.Scanner;

public class Pattern_1 {

public static void main(String[] args) {
Scanner s= new Scanner(System.in);
System.out.println("Enter Number");
int n = s.nextInt();
int i=1;

while(i<=n)
{ int j=1;
while(j<=n) {
System.out.print("*");
j=j+1;
}
System.out.println();
i=i+1;
}




}

}
31 changes: 31 additions & 0 deletions Patterns/alpha_sequence_pattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


import java.util.Scanner;

public class Alpha_pattern_2 {

public static void main(String[] args) {
// TODO Auto-generated method stub
//ABCD
//BCDE
//CDEF
//DEFG
Scanner s= new Scanner(System.in);
System.out.println("Enter value of n");
int n = s.nextInt();
int i=1;
while(i<=n)
{ char ch=(char)('A'+i-1) ;
int j=1;
while(j<=n){
System.out.print(ch);
ch=(char)(ch+1);
j=j+1;
}
System.out.println();
i=i+1;
}

}

}
59 changes: 59 additions & 0 deletions Patterns/diamond.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Enter the number of rows: 4
Enter symbol as you wish:
*
*
***
*****
*******
*****
***
*
*/

import java.util.Scanner;

public class diamond {

public static void main(String[] args) {

int i,j;
Scanner scan=new Scanner(System.in);
System.out.print("Enter the number of rows: ");
int rows=scan.nextInt();
System.out.println("Enter symbol as you wish: ");
char ch=scan.next().charAt(0);
//read number input from user
i=1;
while(i<=rows){//first outer while loop iterates through the row
j=1;
while(j<=rows-i){
System.out.print(" ");//print star
j++;
}
j=1;
while(j<=i*2-1){
System.out.print(ch);//print given symbol
j++;
}
System.out.println();//move to next line
i++;
}
i=rows-1;
while(i>=0){//second outer while loop
j=1;
while(j<=rows-i){
System.out.print(" ");//print space - inner wile loop
j++;
}
j=1;
while(j<=i*2-1){
System.out.print(ch);//print given symbol - inner while loop
j++;
}
System.out.println();
i--;
}
}

}
36 changes: 36 additions & 0 deletions Patterns/half_astrick_pyramid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@


import java.util.Scanner;

public class pyramid_2 {

public static void main(String[] args) {
// *
// **
// ***
// ****
Scanner s= new Scanner(System.in);
System.out.println("Enter Height of pyramid");
int n = s.nextInt();
int i=1;
while(i<=n)
{
int j=1;
while(j<=n-i){
System.out.print(" ");
j=j+1;
}
int star=1;
while(star<=i) {
System.out.print("*");
star=star+1;
}

System.out.println();
i=i+1;
}


}

}
40 changes: 40 additions & 0 deletions Patterns/isoceles_traingle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


import java.util.Scanner;

public class isoceles_traingle {

public static void main(String[] args) {
// 1
// 121
//12321
Scanner s= new Scanner(System.in);
System.out.println("Enter number of row");
int n = s.nextInt();
int i=1;
while(i<=n)
{
int j=1;
while(j<=n-i){
System.out.print(" ");
j=j+1;
}
int num=1;
while(num<=i) {
System.out.print(num);
num=num+1;
}
int num1=i-1;
while(num1>=1) {
System.out.print(num1);
num1=num1-1;

}

System.out.println();
i=i+1;
}

}

}
32 changes: 32 additions & 0 deletions Patterns/number_right_traingle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


import java.util.Scanner;

public class traingle_pattern_2 {

public static void main(String[] args) {
// TODO Auto-generated method stub
//1
//23
//456
//78910
Scanner s= new Scanner(System.in);
System.out.println("Enter Height of of right angle traingle");
int n = s.nextInt();
int i=1;
int count=1;
while(i<=n)
{ int j=1;

while(j<=i) {
System.out.print(count);
count+=1;
j=j+1;
}
System.out.println();
i=i+1;
}

}

}
29 changes: 29 additions & 0 deletions Patterns/number_row_sequence_square_pattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


import java.util.Scanner;

public class pattern_3 {

public static void main(String[] args) {
//1234
//1234
//1234
//1234

Scanner s= new Scanner(System.in);
System.out.println("enter width of square");
int n = s.nextInt();
int i=1;

while(i<=n)
{ int j=1;
while(j<=n) {
System.out.print(j);
j=j+1;
}
System.out.println();
i=i+1;
}
}

}
35 changes: 35 additions & 0 deletions Patterns/number_sequence_pattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

import java.util.Scanner;

public class traingle_pattern_3 {

public static void main(String[] args) {
// TODO Auto-generated method stub
//1
//23
//345
//4567
Scanner s= new Scanner(System.in);
System.out.println("Enter n ");
int n = s.nextInt();
int i=1;

while(i<=n)
{ int j=1;
int count=i;
while(j<=i) {
System.out.print(count);
count+=1;
j=j+1;


}
System.out.println();

i=i+1;
}


}

}
Loading