Monday, August 12, 2019

BlueJ Programs On Two Patterns






Display the pattern using BlueJ program.

 1
333
55555
7777777
999999999
7777777
55555
333


1


class BlueJS
{
public void show()
{
int x=1;
for(int i=0; i< 5; i++)
{
for(int j=0; j< i*2+1; j++)
{
 System.out.print( x );
}
x=x+2;
System.out.println ( );
}
x=x-4;
for(int i=0; i< 4; i++)
{
for(int j=0; j< 7 - i*2; j++)
{
 System.out.print( x );
}
x=x-2;
System.out.println ( );
}
}
}

 Display the pattern using BlueJ program.
  
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 BlueJS
{
public void show()
{
int x=1;
for(int i=0; i< 5; i++)
{
for(int j=0; j< i*2+1; j++)
{
if(j%2==0)
 System.out.print( x );
else
System.out.print(" ");

}
x=x+1;
System.out.println ( );
}
x=x-2;
for(int i=0; i< 4; i++)
{
for(int j=0; j< 7 - i*2; j++)
{
 if(j%2==0)
 System.out.print( x );
else
System.out.print(" ");
 }
x=x-1;
System.out.println ( );
}
}
 }


Related Post: BlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner