Tuesday, December 30, 2014

BlueJ Program To Print The Series Of Numbers And Star


The pattern would be like:

     1 2 3 4 *
     1 2 3 * 5
     1 2 * 4 5
     1 * 3 4 5
     * 2 3 4 5
    

Here is the BlueJ program.



class S
{
  
   int i,j;
   int x;
    public void show()
    {
        for(i=0;i< 5;i++)
        {
            x=1;
            for(j=0;j< 5;j++)
            {
                 if(i+j==4)
                 System.out.print("*");
                 else
                 System.out.print(x++);
                }
                System.out.println();
            }     
    }
        public static void main(String args[])
        {
             S ob=new S();
             ob.show();
            }

        }

Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner