Sunday, March 29, 2015

Two Patterns Using BlueJ Program


Two patterns as given below will be printed using BlueJ program.

The patterns are:

e

ed
edc
edcb
edcba

and


a c e g

i k m
o q
s

First pattern program.

class A

{
 public void showPattern()
 {
 int i,j,x;
 for(i=0;i<=4;i++)
 {
  x=101;
  for(j=0;j<=i;j++)
  {
  System.out.print((char)x);
  x--;
  }
  System.out.println();
  }
  }
   public static void main(String args[])
  {
   A ob=new A();
   ob.showPattern();
   }
   }

   Second pattern program



class A
{
 public void showPattern()
 {
 int i,j,x=97;
 for(i=0;i<=3;i++)
 {
  
  for(j=i;j<=3;j++)
  {
  System.out.print((char)x);
  x=x+2;
  }
  System.out.println();
  }
  }
   public static void main(String args[])
  {
   A ob=new A();
   ob.showPattern();
   }
   }



Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner