Thursday, August 7, 2014

BlueJ Pattern Program


In this program we will display the following pattern:

1
2 2
3 3 3
4 4 4 4
n n n n n
4 4 4 4
3 3 3
2 2
1

public class A
{
int i,j,x,y;
public void show()
{
x=1;
y=1;

 for(i=1;i<=9;i++)
 {

  for(j=1;j<=x;j++)
      {
          if(i==5)
          System.out.print("n");
          else
          System.out.print(y);
        }
        if(i<=9/2)
        {
            y++;
        x++;
    }
        else
        {
            y--;
        x--;
    }
     System.out.println();
     }
}
public static void main(String args[])
{
 A ob=new A();
 ob.show();
}
}


Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner