Letter Patterns Program

Letter Patterns Program:


1.* *  * *  

   *           *
   *           *
   *  *  * * 
   *           *
   *           *
   *           * 


class R
{
       public static void main(String args[])
       {
              for(int x=1;x<=7;x++)
              {
                     for(int y=1;y<=5;y++)
                     {
                            if(x==1 && y<=4 || y<=1||
                                x==4 && y<=4 ||
                                x>=2 && x<=6 && x!=4 && y==5 ||
                                x==7 && y==5)
                            {
                                   System.out.print("* ");
                            }
                            else
                            {
                                   System.out.print(" ");
                            }
                     }
                     System.out.println();
              }
       }
}


2.* * * * 
   *          *
   *          *
   *          *
   *          *
   *          *
   * * * *   

class D
{
       public static void main(String args[])
       {
              for(int x=1;x<=7;x++)
              {
                     for(int y=1;y<=5;y++)
                     {
                            if((x==1 || x==7) && y>=2 && y<=4 ||
                               (x>=2 || x<=6) && y==1 || y==5 && x>=2
                                                                                   && x<=6)
                            {
                                   System.out.print("* ");
                            }
                            else
                            {
                                   System.out.print(" ");
                            }
                     }
                     System.out.println();
              }
       }
}


3.   * * * 
   *          *
   *       
      * * * 
               *
               *
   * * * *   

class S
{
      public static void main(String args[])
     {
            for(int x=1;x<=7;x++)
           {
                 for(int y=1;y<=5;y++)
                 {
                      if(x==1 && y!=1 && y!=5 || x==2 &&
                        (!(y>=2  && y<=4)) || x==3 && y==1 ||
                        x==4 && y!=1 && y!=5|| x==5 && y==5 ||
                        x==6 && y==5 || x==7 && y!=5)
                     {
                           System.out.print("* ");
                     }
                     else
                     {
                           System.out.print("  ");
                     }
                } 
                System.out.println();
           }
      }
}


4.*         *
   * *   * *
   *   *    *
   *         *
   *         *
   *         *
   *         * 

class M
{
      public static void main(String args[])
      {
            for(int x=1;x<=7;x++)
            {
                  for(int y=1;y<=5;y++)
                  {
                         if(y<=1 || x==y && x<=3 || y==5 || x==2 && y==4)
                         {
                               System.out.print("* ");
                         }
                         else
                         {
                               System.out.print(" ");
                         }
                  }
                  System.out.println();
            }
      }
}


5.  * * *
   *         *
  *
  *
  *
   *         *
     * * *

class C
{
       public static void main(String args[])
       {
              for(int x=1;x<=7;x++)
              {
                     for(int y=1;y<=5;y++)
                     {
                            if(y==1 && x>=2 && x<=6 || (x==1 ||
                               x==7) && y>=2 && y<=4 || (x==2 ||
                               x==6) && y==5)
                            {
                                   System.out.print("* ");
                            }
                            else
                            {
                                   System.out.print(" ");
                            }
                     }
                     System.out.println();
              }
       }
}


6.   * * *
    *          *
   *           *
   *           *
   *           *
    *          *
       * * *

class O
{
       public static void main(String args[])
       {
              for(int x=1;x<=7;x++)
              {
                     for(int y=1;y<=5;y++)
                     {
                            if(y==5 && x>=2 && x<=6 ||
                               (x==1 || x==7) && y>=2 && y<=4 ||
                                y==1 && x>=2 && x<=6 )
                            {
                                   System.out.print("x ");
                            }
                            else
                            {
                                   System.out.print("  ");
                            }
                     }
                     System.out.println();
              }
       }
}

Post a Comment

0 Comments