Tuesday, December 4, 2012

BlueJ Program On Pattern




School students of ICSE and ISC board needs practice on lot of pattern programs. Here is a pattern program as given below:

12341
21432
34123
43214

class Pattern
{
int i,j,x;
 public void show()
 {
      for(i=0;i< 4;i++)
     {
          x=i+1;
           for(j=0;j< 5;j++)
         {
                System.out.print(x);
                if(i%2==0)
                x++;
                else
                x--;
                if(i%2==0 && x>4)
                x=1;
                else if(i%2!=0 && x< 1)
                x=4;
            }
            System.out.println();
        }
    }
public static void main(String args[])
{
 Pattern ob=new Pattern();
ob.show();
}
}


Related PostBlueJ Programs On Pattern


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner