0% found this document useful (0 votes)
670 views3 pages

Programs On Pattern Printing Using Bluej

The document contains code for 6 different pattern printing programs in Java using the BlueJ IDE. Each program uses loops and conditionals to print numeric or character patterns of increasing or decreasing size. The patterns include triangles, diamonds, numbers, and letters.

Uploaded by

Dipankar Rot
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
670 views3 pages

Programs On Pattern Printing Using Bluej

The document contains code for 6 different pattern printing programs in Java using the BlueJ IDE. Each program uses loops and conditionals to print numeric or character patterns of increasing or decreasing size. The patterns include triangles, diamonds, numbers, and letters.

Uploaded by

Dipankar Rot
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 3

PROGRAMS ON PATTERN PRINTING USING BLUEJ

} }
Pattern number 1
_1____
___121___
__12321__
_1234321_
123454321
class Pat
{
int i,j,k,m,x=1;
public void show()
{
for(i=0;i< 5;i++)
{
x=1;
for(m=i;m< 4;m++)
System.out.print(" ");
for(j=0;j< =i;j++)
{
System.out.print(x++);
}
x=x-2;
for(j=0;j< i;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void
main(String args[])
{
Pat ob=new Pat();
ob.show();

Pattern number 2
.____A
___AA
__AAA
_AAAA
AAAAA
_AAAA
__AAA
___AA
____A
class Pat
{
int i,j,m,x=4;
public void show()
{
for(i=0;i< 9;i++)
{
for(m=0;m< x;m++)
System.out.print(" ");
for(j=0;j< =4-x;j++)
{
System.out.print("A");
}
if(i< 8/2)
x--;
else
x++;
System.out.println();
}
}
public static void
main(String args[])
{
Pat ob=new Pat();

ob.show();
} }
Pattern number 3

54321
4321
321
21
1
class Pat
{
int i,j,m,x;
public void show()
{
for(i=0;i< 5;i++)
{
x=5-i;
for(m=0;m< i;m++)
System.out.print(" ");
for(j=0;j< 5-i;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void
main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}

Pattern 4
-----------1234567-------------------23456--------------------345-----------------------4-----------------------345---------------------23456-------------------1234567--------class BlueJx
{
public void show()
{
int j,x;
for(int i=0;i< 4;i++)
{
x=1;
for(j=0;j< i;j++)
{
x++;
System.out.print(" ");
}
for(int k=i+j;k< 7;k++)
System.out.print(x++);
System.out.println();
}
for(int i=0;i< 3;i++)
{
x=1;
for(j=i;j< 2;j++)
{
x++;
System.out.print(" ");
}
for(int k=0;k< 3+i*j;k++)
System.out.print(x++);
System.out.println();
}
}
}

x=x+2;
} } }
Pattern 5
------------1------------------2_2----------------3_3_3--------------4_4_4_4-------------5_5_5_5_5-------------4_4_4_4---------------3_3_3-----------------2_2-------------------1---------class BlueJx
{
public void show()
{
int j,x=1;
for(int i=1;i< =5;i++)
{
for(j=1;j< =5-i;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
if(k%2==0)
System.out.print(i);
else
System.out.print(" ");
}
System.out.println();
x=x+2;
}
x=1;
for(int i=4;i >=1;i--)
{
for(j=i;j< =4;j++)
{
System.out.print(" ");
}
for(int k=0;k< =7-x;k++)
{
if(k%2==0)
System.out.print(i);
else
System.out.print(" ");
}
System.out.println();

Pattern 6
--------------1----------------------333--------------------55555------------------7777777----------------999999999----------------7777777------------------55555--------------------333----------------------1---------class BlueJx
{
public void show()
{
int j,x=1;
for(int i=1;i< =5;i++)
{
for(j=1;j< =5-i;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
System.out.print(x);
}
System.out.println();
x=x+2;
}
x=x-4;
for(int i=4;i >=1;i--)
{
for(j=i;j< =4;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
System.out.print(x);
}
System.out.println();
x=x-2;
} } }

6 12
6 12 18
6 12 18 24
class BlueJx
{
public void show(int n)
{
int j,x;
for(int i=0;i< n;i++)
{
x=6;
for(j=0;j< =i;j++)
{
System.out.print(" "+x);
x=x+6;
}
System.out.println();
}} }

You might also like