Saturday, October 16, 2010

BlueJ Pattern


Using BlueJ print the pattern


12345678910
13579
14710
159
16
17
18
19
110
1


class BlueJx
{
 public void show()
 {
 int j,x=1,y=0;
  for(int i=0;i< 10;i++)
  {
  x=1;
   while(x< =10)
   {
     System.out.print(x);
     x=x+y+1;
  }
    y=y+1;
    System.out.println();
 }
 }
   public static void main(String args[])
   {
    BlueJx ob=new BlueJx();
    ob.show();
   }
  }

 In this above BlueJ program, 10 rows of numbers are printed. The numbers are generated with some interval. The interval starts with '0' and gradually increases by '1' after each increase in row. The maximum number in a row can be 10.

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner