0% found this document useful (0 votes)
63 views14 pages

Java Pattern Printing Programs

The document contains a series of Java programs that generate various patterns using nested loops. Each program demonstrates different output styles, including stars, numbers, and letters arranged in specific formats. The patterns include solid shapes, decreasing sequences, and alternating characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views14 pages

Java Pattern Printing Programs

The document contains a series of Java programs that generate various patterns using nested loops. Each program demonstrates different output styles, including stars, numbers, and letters arranged in specific formats. The patterns include solid shapes, decreasing sequences, and alternating characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Pattern programs

1 *****
*****
*****
*****
*****
import [Link].*;
class nested
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=5;p++)
{
[Link]("*");
}
[Link]();
}
}
}
2 12345
12345
12345
12345
12345
import [Link].*;
class nested1
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=5;p++)
{
[Link](p);
}
[Link]();
}
}
}
3 54321
54321
54321
54321
54321
import [Link].*;
class nested2
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=5;p>=1;p--)
{
[Link](p);
}
[Link]();
}
}
}
4 11111
22222
33333
44444
55555
import [Link].*;
class nested3
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=5;p++)
{
[Link](k);
}
[Link]();
}
}
}
5 55555
44444
33333
22222
11111
import [Link].*;
class nested18
{
static void main()
{
int k,p;
for(k=5;k>=1;k--)
{
for(p=1;p<=5;p++)
{
[Link](k);
}
[Link]();
}
}
}
6 ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
import [Link].*;
class nested11
{
static void main()
{
char k,p;
for(k='A';k<='E';k++)
{
for(p='A';p<='E';p++)
{
[Link](p+" ");
}
[Link]();
}
}
}
7 AAAAA
BBBBB
CCCCC
DDDDD
E E E E E
import [Link].*;
class nested19
{
static void main()
{
char k,p;
for(k='A';k<='E';k++)
{
for(p='A';p<='E';p++)
{
[Link](k+" ");
}
[Link]();
}
}
}
8 EEEEE
DDDDD
CCCCC
BBBBB
AAAAA
import [Link].*;
class nested21
{
static void main()
{
char k,p;
for(k='E';k>='A';k--)
{
for(p='A';p<='E';p++)
{
[Link](k+" ");
}
[Link]();
}
}
}
9 EDCBA
EDCBA
EDCBA
EDCBA
EDCBA
import [Link].*;
class nested20
{
static void main()
{
char k,p;
for(k='A';k<='E';k++)
{
for(p='E';p>='A';p--)
{
[Link](p+" ");
}
[Link]();
}
}
}

10 *
**
***
****
*****
import [Link].*;
class nested14
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=k;p++)
{
[Link]("*");
}
[Link]();
}
}
}
11 1
12
123
1234
12345
import [Link].*;
class nested4
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=k;p++)
{
[Link](p);
}
[Link]();
}
}
}
12 12345
1234
123
12
1
import [Link].*;
class nested16
{
static void main()
{
int k,p;
for(k=5;k>=1;k--)
{
for(p=1;p<=k;p++)
{
[Link](p);
}
[Link]();
}
}
}
13 5
54
543
5432
54321
import [Link].*;
class nested22
{
static void main()
{
int k,p;
for(k=5;k>=1;k--)
{
for(p=5;p>=k;p--)
{
[Link](p);
}
[Link]();
}
}
}
14 54321
5432
543
54
5
import [Link].*;
class nested5
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=5;p>=k;p--)
{
[Link](p);
}
[Link]();
}
}
}
15 1
22
333
4444
55555
import [Link].*;
class nested6
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=k;p++)
{
[Link](k);
}
[Link]();
}
}
}
16 55555
4444
333
22
1
import [Link].*;
class nested7
{
static void main()
{
int k,p;
for(k=5;k>=1;k--)
{
for(p=1;p<=k;p++)
{
[Link](k);
}
[Link]();
}
}
}
17 1
23
456
7 8 9 10
11 12 13 14 15
import [Link].*;
class nested8
{
static void main()
{
int k,p;
int n=1;
for(k=1;k<=5;k++)
{
for(p=1;p<=k;p++)
{
[Link](n+" ");
n++;
}
[Link]();
}
}
}
18 1
21
321
4321
54321
import [Link].*;
class nested9
{
static void main()
{
int k,p;
for (k=1;k<=5;k++)
{
for (p=k;p>=1;p--)
{
[Link](p + " ");
}
[Link]();
}
}
}

19 1
10
101
1010
10101
import [Link].*;
class nested10
{
static void main()
{
int k,p,a=1,b=0;
for (k=1;k<=5;k++)
{
for (p=1;p<=k;p++)
{
if(p%2==0)
[Link](b + " ");
else
[Link](a + " ");
}
[Link]();
}
}
}

20 1
11
111
1111
11111
import [Link].*;
class nested15
{
static void main()
{
int k,p;
for(k=1;k<=5;k++)
{
for(p=1;p<=k;p++)
{
[Link]("1");
}
[Link]();
}
}
}
21 A
BB
CCC
D DDD
EEEEE
import [Link].*;
class nested12
{
static void main()
{
char k,p;
for(k='A';k<='E';k++)
{
for(p='A';p<=k;p++)
{
[Link](k);
}
[Link]();
}
}
}
22 EEEEE
DDDD
CCC
BB
A
import [Link].*;
class nested23
{
static void main()
{
char k,p;
for(k='E';k>='A';k--)
{
for(p='A';p<=k;p++)
{
[Link](k +" ");
}
[Link]();
}
}
}
23 A
BC
DEF
GHIJ
KLMNO
import [Link].*;
class nested24
{
static void main()
{
char k,p;
char n='A';
for(k='A';k<='E';k++)
{
for(p='A';p<=k;p++)
{
[Link](n+" ");
n++;
}
[Link]();
}
}
}

You might also like