Create and Move your name in Java

Hello there, Welcome to my blog programmingscoop. Today I'm going to tell you an  interesting program for improving your pattern designing skill. So read the full blog to understand structure of program and share it with your friends for improving their knowledge and also if you have any suggestion,query so comment below tell me the topic which you want to discuss in comment i will help you.

About Program

It is simple program in which you have to enter your first name and this program will create your name in star form and also it will move the display from left to right and vice versa. It is written in java.Here, i'm only make you understand the working of program you can download the whole program form here.    
you can see the output of program in below image:-

Output of name
Output
 

Let's start 

In this program letter is formed in two parts upper and lower.as shown below 


Formation of character
Formation of character



For this program I'm going to use only one module for taking input.

    1. import java.util.Scanner; //for taking input  

Now, In this program i have created two class Main and Letter class for doing our task.so discuss both class one by one.

Main class:-

This class is main class of program which control the whole program it contains the main method and it also have the object of Letter class . This class will take input from user and identify the letters one by one. In this class one first letter is created and all other letters are created by calling the methods of  

  1.  /*Main class*/
  2. class main
  3. {
  4.     public static void main(String args[])
  5.     {    
  6.         Letter obj=new Letter();              //letter class object
  7.         Scanner sc=new Scanner(System.in);    //for taking input
  8.         String name=new String();             //represent user input
  9.         /*********        declaration of variables ***************/
  10.         int u_left=0,u_right=0,u_top=0,u_bottom=0,u_rline=0,u_middle=0;        //upper_structure
  11.         int d_left=0,d_right=0,d_bottom=0,d_rline=0,d_leftline=0,d_middle=0; //lower structure
  12.         int i,j,n,t,lextra=0,rextra=0;        
  13.         int rev=0;
  14.         int exception=0;
  15.         
  16.         ///taking input from user
  17.         System.out.println("Enter you first name in small letters:");
  18.         name=sc.nextLine();
  19.             
  20.                 
  21.             for(int time=1;time<=75;time++)        //for moving letter on screen
  22.             {    
  23.                 if(time>=40){rev=rev+2;}   //used to reverse the moving order
  24.                 
  25.                 try
  26.                 {
  27.                     Thread.sleep(70);                    //for holding program
  28.                     System.out.print("\033[H\033[2J");  //for clearing screen
  29.                     System.out.flush();
  30.                 }
  31.                 catch(Exception e)
  32.                 {
  33.                 }
  34.                 /******        upper structure   ********/
  35.                     for(i=1;i<=5;i++)
  36.                     {    
  37.                         //it moves the letter form left to right
  38.                         if(time<=39)
  39.                         {
  40.                             for(int t2=1;t2<=time;t2++)
  41.                             {
  42.                                 System.out.print(" ");
  43.                             }
  44.                         }
  45.                         //it moves the letter form right to left
  46.                         if(time>=40)
  47.                         {
  48.                             for(int t2=1;t2<=time-rev;t2++)
  49.                             {
  50.                                 System.out.print(" ");
  51.                             }
  52.                         }
  53.                             switch(name.charAt(0))
  54.                             {
  55.                                 case 'a':
  56.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  57.                                 break;
  58.                                 case 'b':
  59.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  60.                                 break;
  61.                                 case 'c':
  62.                                     u_right=0;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  63.                                 break;
  64.                                 case 'd':
  65.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  66.                                 break;
  67.                                 case 'e':
  68.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  69.                                 break;
  70.                                 case 'f':
  71.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  72.                                 break;
  73.                                 case 'g':
  74.                                     lextra=0;rextra=0;exception=1;obj.g(i,0);
  75.                                 break;
  76.                                 case 'h':
  77.                                     u_right=1;u_left=1;u_top=0;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  78.                                 break;
  79.                                 case 'i':
  80.                                     u_right=0;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  81.                                 break;
  82.                                 case 'j':
  83.                                     u_right=1;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=1;rextra=0;exception=0;
  84.                                 break;
  85.                                 case 'k':
  86.                                     u_right=0;u_left=1;u_top=0;u_bottom=0;u_rline=1;u_middle=0;lextra=0;rextra=0;exception=0;
  87.                                 break;
  88.                                 case 'l':
  89.                                     u_right=0;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  90.                                 break;
  91.                                 case 'm':
  92.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  93.                                 break;
  94.                                 case 'n':
  95.                                     lextra=0;rextra=0;exception=1;obj.n(i,0);
  96.                                 break;
  97.                                 case 'o':
  98.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  99.                                 break;
  100.                                 case 'p':
  101.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  102.                                 break;
  103.                                 case 'q':
  104.                                     lextra=0;rextra=0;exception=1;obj.q(i,0);
  105.                                 break;
  106.                                 case 'r':
  107.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  108.                                 break;
  109.                                 case 's':
  110.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;rextra=1;lextra=0;exception=0;
  111.                                 break;
  112.                                 case 't':
  113.                                     u_right=0;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  114.                                 break;
  115.                                 case 'u':
  116.                                     u_right=1;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  117.                                 break;
  118.                                 case 'v':
  119.                                     lextra=0;rextra=0;exception=1;obj.v(i,0);
  120.                                 break;
  121.                                 case 'w':
  122.                                     u_right=1;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  123.                                 break;
  124.                                 case 'x':
  125.                                     lextra=0;rextra=0;exception=1;obj.x(i,0);
  126.                                 break;
  127.                                 case 'y':
  128.                                     u_right=1;u_left=1;u_top=0;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  129.                                 break;
  130.                                 case 'z':
  131.                                     lextra=0;rextra=0;exception=1;obj.z(i,0);
  132.                                 break;
  133.                                 
  134.                                 default: System.out.println("Wrong input");break;
  135.                             }
  136.                         
  137.                         if(exception==0)    
  138.                         {     
  139.                             if(u_left==1)
  140.                             System.out.print("*");
  141.                             
  142.                             if(lextra==1 && i==1)
  143.                             {
  144.                                 System.out.print("*");
  145.                             }
  146.                             else if(lextra==1)
  147.                             {
  148.                                 System.out.print(" ");
  149.                             }
  150.                                                 
  151.                             for(j=1;j<=3;j++)
  152.                             {    
  153.                                 if(i==u_top || i==u_bottom)
  154.                                     System.out.print("*");
  155.                                 else if(u_rline==1)
  156.                                 {
  157.                                     if((i==2 && j==3)||(i==3 && j==2)||(i==4 && j==1))
  158.                                         {
  159.                                             System.out.print("*");
  160.                                         }
  161.                                         else{System.out.print(" ");}
  162.                                 }
  163.                                 else if(u_middle==1)
  164.                                 {
  165.                                     if((i==2 && j==2)||(i==3 && j==2)||(i==4 && j==2)|| (i==5 && j==2))
  166.                                         {
  167.                                             System.out.print("*");
  168.                                         }
  169.                                         else{System.out.print(" ");}
  170.                                 }
  171.                                 else
  172.                                     System.out.print(" ");
  173.                             }
  174.                             if(u_right==1)
  175.                             {
  176.                                 System.out.print("*");
  177.                             }
  178.                             if(rextra==1 && (i==1 || i==5))
  179.                             {
  180.                                 System.out.print("*");
  181.                             }
  182.                             else if(rextra==1)
  183.                             {
  184.                                 System.out.print(" ");
  185.                             }
  186.                         }    
  187.                         /************  used for creating letters more than 2 *****************/
  188.                         for(t=2;t<=name.length();t++)
  189.                         {    System.out.print("  ");lextra=0;rextra=0;
  190.                             switch(name.charAt(t-1))
  191.                             {
  192.                                 case 'a':
  193.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  194.                                 break;
  195.                                 case 'b':
  196.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  197.                                 break;
  198.                                 case 'c':
  199.                                     u_right=0;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  200.                                 break;
  201.                                 case 'd':
  202.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  203.                                 break;
  204.                                 case 'e':
  205.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  206.                                 break;
  207.                                 case 'f':
  208.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  209.                                 break;
  210.                                 case 'g':
  211.                                     lextra=0;rextra=0;exception=1;obj.g(i,0);
  212.                                 break;
  213.                                 case 'h':
  214.                                     u_right=1;u_left=1;u_top=0;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  215.                                 break;
  216.                                 case 'i':
  217.                                     u_right=0;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  218.                                 break;
  219.                                 case 'j':
  220.                                     u_right=1;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=1;rextra=0;exception=0;
  221.                                 break;
  222.                                 case 'k':
  223.                                     u_right=0;u_left=1;u_top=0;u_bottom=0;u_rline=1;u_middle=0;lextra=0;rextra=0;exception=0;
  224.                                 break;
  225.                                 case 'l':
  226.                                     u_right=0;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  227.                                 break;
  228.                                 case 'm':
  229.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  230.                                 break;
  231.                                 case 'n':
  232.                                     lextra=0;rextra=0;exception=1;obj.n(i,0);
  233.                                 break;
  234.                                 case 'o':
  235.                                     u_right=1;u_left=1;u_top=1;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  236.                                 break;
  237.                                 case 'p':
  238.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  239.                                 break;
  240.                                 case 'q':
  241.                                     lextra=0;rextra=0;exception=1;obj.q(i,0);
  242.                                 break;
  243.                                 case 'r':
  244.                                     u_right=1;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  245.                                 break;
  246.                                 case 's':
  247.                                     u_right=0;u_left=1;u_top=1;u_bottom=5;u_rline=0;u_middle=0;rextra=1;lextra=0;exception=0;
  248.                                 break;
  249.                                 case 't':
  250.                                     u_right=0;u_left=0;u_top=1;u_bottom=0;u_rline=0;u_middle=1;lextra=0;rextra=0;exception=0;
  251.                                 break;
  252.                                 case 'u':
  253.                                     u_right=1;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  254.                                 break;
  255.                                 case 'v':
  256.                                     lextra=0;rextra=0;exception=1;obj.v(i,0);
  257.                                 break;
  258.                                 case 'w':
  259.                                     u_right=1;u_left=1;u_top=0;u_bottom=0;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  260.                                 break;
  261.                                 case 'x':
  262.                                     lextra=0;rextra=0;exception=1;obj.x(i,0);
  263.                                 break;
  264.                                 case 'y':
  265.                                     u_right=1;u_left=1;u_top=0;u_bottom=5;u_rline=0;u_middle=0;lextra=0;rextra=0;exception=0;
  266.                                 break;
  267.                                 case 'z':
  268.                                     lextra=0;rextra=0;exception=1;obj.z(i,0);
  269.                                 break;
  270.                                 
  271.                                 default: System.out.println("Wrong input");break;
  272.                             }
  273.                             /*  used to create letter if letter are more than 1*/
  274.                             obj.up(i,u_left,u_right,u_top,u_bottom,u_rline,u_middle,rextra,lextra,exception);
  275.                         }
  276.                             System.out.println();
  277.                     }
  278.                 /****** creating down structure of letter **************/
  279.                 
  280.                 lextra=0;rextra=0;exception=0;
  281.                 
  282.                 for(i=1;i<=4;i++)
  283.                 {    
  284.                     //for moving letter form left to right
  285.                     if(time<=39)
  286.                     {
  287.                         for(int t2=1;t2<=time;t2++)
  288.                         {
  289.                             System.out.print(" ");
  290.                         }
  291.                     }
  292.                     //for moving letter from right to left
  293.                     if(time>=40)
  294.                     {                
  295.                         for(int t2=1;t2<=time-rev;t2++)
  296.                         {
  297.                             System.out.print(" ");
  298.                         }
  299.                     }
  300.                         switch(name.charAt(0))
  301.                         {
  302.                             case 'a':
  303.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  304.                             break;
  305.                             case 'b':
  306.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  307.                             break;
  308.                             case 'c':
  309.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  310.                             break;
  311.                             case 'd':
  312.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  313.                             break;
  314.                             case 'e':
  315.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  316.                             break;
  317.                             case 'f':
  318.                                 d_right=0;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  319.                             break;
  320.                             case 'g':
  321.                                 exception=1;rextra=0;lextra=0;obj.g(0,i);
  322.                             break;
  323.                             case 'h':
  324.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  325.                             break;
  326.                             case 'i':
  327.                                 d_right=0;d_left=0;d_bottom=4;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  328.                             break;
  329.                             case 'j':
  330.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  331.                             break;
  332.                             case 'k':
  333.                                 d_right=0;d_left=1;d_bottom=0;d_rline=1;d_middle=0;lextra=0;rextra=0;exception=0;
  334.                             break;
  335.                             case 'l':
  336.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  337.                             break;
  338.                             case 'm':
  339.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  340.                             break;
  341.                             case 'n':
  342.                                 exception=1;rextra=0;lextra=0;obj.n(0,i);
  343.                             break;
  344.                             case 'o':
  345.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  346.                             break;
  347.                             case 'p':
  348.                                 d_right=0;d_left=1;d_bottom=0;d_rline=0;d_middle=0;rextra=1;lextra=0;exception=0;
  349.                             break;
  350.                             case 'q':
  351.                                 exception=1;rextra=0;lextra=0;obj.q(0,i);
  352.                             break;
  353.                             case 'r':
  354.                                 d_right=0;d_left=1;d_bottom=0;d_rline=1;d_middle=0;rextra=1;lextra=0;exception=0;
  355.                             break;
  356.                             case 's':
  357.                                 d_right=1;d_left=0;d_bottom=4;d_rline=0;d_middle=0;lextra=1;rextra=0;exception=0;
  358.                             break;
  359.                             case 't':
  360.                                 d_right=0;d_left=0;d_bottom=0;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  361.                             break;
  362.                             case 'u':
  363.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  364.                             break;
  365.                             case 'v':
  366.                                 exception=1;rextra=0;lextra=0;obj.v(0,i);
  367.                             break;
  368.                             case 'w':
  369.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  370.                             break;
  371.                             case 'x':
  372.                                 exception=1;rextra=0;lextra=0;obj.x(0,i);
  373.                             break;
  374.                             case 'y':
  375.                                 d_right=1;d_left=0;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  376.                             break;
  377.                             case 'z':
  378.                                 exception=1;rextra=0;lextra=0;obj.z(0,i);
  379.                             break;
  380.                             
  381.                             default: System.out.println("Wrong input");break;
  382.                         }
  383.                     
  384.                                         
  385.                     if(exception==0)
  386.                     {
  387.                         if(d_left==1)
  388.                         System.out.print("*");
  389.                         if(lextra==1 && i==4)
  390.                         {
  391.                             System.out.print("*");
  392.                         }
  393.                         else if(lextra==1)
  394.                         {
  395.                             System.out.print(" ");
  396.                         }
  397.                         for(j=1;j<=3;j++)
  398.                         {
  399.                             if(i==d_bottom)
  400.                                 System.out.print("*");
  401.                             else if(d_rline==1)
  402.                             {
  403.                                 if((i==1 && j==1)||(i==2 && j==2)||(i==3 && j==3))
  404.                                     {
  405.                                         System.out.print("*");
  406.                                     }
  407.                                     else{System.out.print(" ");}
  408.                             }
  409.                             else if(d_middle==1)
  410.                             {
  411.                                 if((i==2 && j==2)||(i==3 && j==2)||(i==4 && j==2)||(i==1 && j==2))
  412.                                     {
  413.                                         System.out.print("*");
  414.                                     }
  415.                                     else{System.out.print(" ");}
  416.                             }
  417.                             else
  418.                                 System.out.print(" ");
  419.                         }
  420.                         if(d_right==1)
  421.                         {
  422.                             System.out.print("*");
  423.                         }
  424.                         if(rextra==1 && i==4 && (d_bottom==4|| d_rline==1))
  425.                             {
  426.                                 System.out.print("*");
  427.                             }
  428.                         else if(rextra==1)
  429.                         {
  430.                             System.out.print(" ");
  431.                         }
  432.                     }
  433.                         
  434.                         ///used for creating more than one letter
  435.                         for(t=2;t<=name.length();t++)
  436.                         {    System.out.print("  ");lextra=0;rextra=0;
  437.                             switch(name.charAt(t-1))
  438.                             {
  439.                             case 'a':
  440.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  441.                             break;
  442.                             case 'b':
  443.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  444.                             break;
  445.                             case 'c':
  446.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  447.                             break;
  448.                             case 'd':
  449.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  450.                             break;
  451.                             case 'e':
  452.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  453.                             break;
  454.                             case 'f':
  455.                                 d_right=0;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  456.                             break;
  457.                             case 'g':
  458.                                 exception=1;rextra=0;lextra=0;obj.g(0,i);
  459.                             break;
  460.                             case 'h':
  461.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  462.                             break;
  463.                             case 'i':
  464.                                 d_right=0;d_left=0;d_bottom=4;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  465.                             break;
  466.                             case 'j':
  467.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  468.                             break;
  469.                             case 'k':
  470.                                 d_right=0;d_left=1;d_bottom=0;d_rline=1;d_middle=0;lextra=0;rextra=0;exception=0;
  471.                             break;
  472.                             case 'l':
  473.                                 d_right=0;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  474.                             break;
  475.                             case 'm':
  476.                                 d_right=1;d_left=1;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  477.                             break;
  478.                             case 'n':
  479.                                 exception=1;rextra=0;lextra=0;obj.n(0,i);
  480.                             break;
  481.                             case 'o':
  482.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  483.                             break;
  484.                             case 'p':
  485.                                 d_right=0;d_left=1;d_bottom=0;d_rline=0;d_middle=0;rextra=1;lextra=0;exception=0;
  486.                             break;
  487.                             case 'q':
  488.                                 exception=1;rextra=0;lextra=0;obj.q(0,i);
  489.                             break;
  490.                             case 'r':
  491.                                 d_right=0;d_left=1;d_bottom=0;d_rline=1;d_middle=0;rextra=1;lextra=0;exception=0;
  492.                             break;
  493.                             case 's':
  494.                                 d_right=1;d_left=0;d_bottom=4;d_rline=0;d_middle=0;lextra=1;rextra=0;exception=0;
  495.                             break;
  496.                             case 't':
  497.                                 d_right=0;d_left=0;d_bottom=0;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  498.                             break;
  499.                             case 'u':
  500.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  501.                             break;
  502.                             case 'v':
  503.                                 exception=1;rextra=0;lextra=0;obj.v(0,i);
  504.                             break;
  505.                             case 'w':
  506.                                 d_right=1;d_left=1;d_bottom=4;d_rline=0;d_middle=1;lextra=0;rextra=0;exception=0;
  507.                             break;
  508.                             case 'x':
  509.                                 exception=1;rextra=0;lextra=0;obj.x(0,i);
  510.                             break;
  511.                             case 'y':
  512.                                 d_right=1;d_left=0;d_bottom=0;d_rline=0;d_middle=0;lextra=0;rextra=0;exception=0;
  513.                             break;
  514.                             case 'z':
  515.                                 exception=1;rextra=0;lextra=0;obj.z(0,i);
  516.                             break;
  517.                             
  518.                             default: System.out.println("Wrong input");break;
  519.                             }
  520.                             //calling method for creating down structure
  521.                             obj.down(i,d_left,d_right,d_bottom,d_rline,d_middle,rextra,lextra,exception);
  522.                         }
  523.                         System.out.println();
  524.                     
  525.                 }
  526.             }    
  527.                 
  528.     }
  529. }

Letter class.

This class is used to create letter after the first letter is created and it also create some of the exception letter like g,n,q,v,w,x,y,z. It contains method like up for creating upper structure and down for creating down structure and method for creating above exceptions letter.

  1. /*This class will create letters after the first letter is created*/
  2. class Letter
  3. {
  4.     /*creating upper stucture of letter*/
  5.     public void up(int i,int u_left,int u_right,int u_top,int u_bottom,int u_rline,int u_middle,int rextra,int lextra,int exception)
  6.     {   
  7.         int j; //temp varible for looping
  8.        
  9.         if(exception==0)
  10.         {   
  11.             if(u_left==1)
  12.                 System.out.print("*");
  13.                        
  14.             if(lextra==1 && i==1)
  15.                 {
  16.                     System.out.print("*");
  17.                 }
  18.             else if(lextra==1)
  19.                 {
  20.                     System.out.print(" ");
  21.                 }
  22.                                            
  23.             for(j=1;j<=3;j++)
  24.             {   
  25.                 if(i==u_top || i==u_bottom)
  26.                     System.out.print("*");
  27.                 else if(u_rline==1)
  28.                 {
  29.                     if((i==2 && j==3)||(i==3 && j==2)||(i==4 && j==1))
  30.                     {
  31.                         System.out.print("*");
  32.                     }
  33.                     else{System.out.print(" ");}
  34.                 }
  35.                 else if(u_middle==1)
  36.                 {
  37.                     if((i==2 && j==2)||(i==3 && j==2)||(i==4 && j==2)|| (i==5 && j==2))
  38.                     {
  39.                         System.out.print("*");
  40.                     }
  41.                     else{System.out.print(" ");}
  42.                 }
  43.                 else
  44.                     System.out.print(" ");
  45.             }
  46.             if(u_right==1)
  47.             {
  48.                 System.out.print("*");
  49.             }
  50.             if(rextra==1 && (i==1 || i==5))
  51.             {
  52.                 System.out.print("*");
  53.             }
  54.             else if(rextra==1)
  55.             {
  56.                 System.out.print(" ");
  57.             }
  58.         }           
  59.     }
  60.     /*creating down structure of letter*/
  61.     public void down(int i,int d_left,int d_right,int d_bottom,int d_rline,int d_middle,int rextra,int lextra,int exception)
  62.     {
  63.         int j;
  64.         if(exception==0)
  65.         {   
  66.             if(d_left==1)
  67.                 System.out.print("*");
  68.             if(lextra==1 && i==4)
  69.             {
  70.                 System.out.print("*");
  71.             }
  72.             else if(lextra==1)
  73.             {
  74.                 System.out.print(" ");
  75.             }
  76.             for(j=1;j<=3;j++)
  77.             {
  78.                 if(i==d_bottom)
  79.                     System.out.print("*");
  80.                 else if(d_rline==1)
  81.                 {
  82.                     if((i==1 && j==1)||(i==2 && j==2)||(i==3 && j==3))
  83.                     {
  84.                         System.out.print("*");
  85.                     }
  86.                     else{System.out.print(" ");}
  87.                 }
  88.                 else if(d_middle==1)
  89.                 {
  90.                     if((i==2 && j==2)||(i==3 && j==2)||(i==4 && j==2)|| (i==1 && j==2))
  91.                     {
  92.                         System.out.print("*");
  93.                     }
  94.                     else{System.out.print(" ");}
  95.                 }
  96.                 else
  97.                     System.out.print(" ");
  98.             }
  99.            
  100.             if(d_right==1)
  101.             {
  102.                 System.out.print("*");
  103.             }
  104.             if(rextra==1 && i==4 && (d_bottom==4|| d_rline==1))
  105.             {
  106.                 System.out.print("*");
  107.             }
  108.             else if(rextra==1)
  109.             {
  110.                 System.out.print(" ");
  111.             }
  112.         }               
  113.     }
  114.     /*for printing n*/
  115.     public void n(int i,int j)
  116.     {
  117.         if(i==1){System.out.print("*       *");}
  118.         if(i==2){System.out.print("**      *");}
  119.         if(i==3){System.out.print("* *     *");}
  120.         if(i==4){System.out.print("*  *    *");}
  121.         if(i==5){System.out.print("*   *   *");}
  122.         if(j==1){System.out.print("*    *  *");}
  123.         if(j==2){System.out.print("*     * *");}
  124.         if(j==3){System.out.print("*      **");}
  125.         if(j==4){System.out.print("*       *");}
  126.     }
  127.     /*for printing g*/
  128.     public void g(int i,int j)
  129.     {
  130.         if(i==1){System.out.print("*********");}
  131.         if(i==2){System.out.print("*        ");}
  132.         if(i==3){System.out.print("*        ");}
  133.         if(i==4){System.out.print("*        ");}
  134.         if(i==5){System.out.print("*   *****");}
  135.         if(j==1){System.out.print("*   *   *");}
  136.         if(j==2){System.out.print("*   *   *");}
  137.         if(j==3){System.out.print("*   *   *");}
  138.         if(j==4){System.out.print("*****   *");}
  139.     }
  140.     /*for printing q*/
  141.     public void q(int i,int j)
  142.     {
  143.         if(i==1){System.out.print("*********");}
  144.         if(i==2){System.out.print("**      *");}
  145.         if(i==3){System.out.print("* *     *");}
  146.         if(i==4){System.out.print("*  *    *");}
  147.         if(i==5){System.out.print("*   *   *");}
  148.         if(j==1){System.out.print("*    *  *");}
  149.         if(j==2){System.out.print("*     * *");}
  150.         if(j==3){System.out.print("*      **");}
  151.         if(j==4){System.out.print("*********");}
  152.     }
  153.     /*for printing v*/
  154.     public void v(int i,int j)
  155.     {
  156.         if(i==1){System.out.print("*       *");}
  157.         if(i==2){System.out.print("*       *");}
  158.         if(i==3){System.out.print("*       *");}
  159.         if(i==4){System.out.print("*       *");}
  160.         if(i==5){System.out.print("*       *");}
  161.         if(j==1){System.out.print(" *     * ");}
  162.         if(j==2){System.out.print("  *   *  ");}
  163.         if(j==3){System.out.print("   * *   ");}
  164.         if(j==4){System.out.print("    *    ");}
  165.     }
  166.     /*for printing x*/
  167.     public void x(int i,int j)
  168.     {
  169.         if(i==1){System.out.print("*       *");}
  170.         if(i==2){System.out.print(" *     * ");}
  171.         if(i==3){System.out.print("  *   *  ");}
  172.         if(i==4){System.out.print("   * *   ");}
  173.         if(i==5){System.out.print("    *    ");}
  174.         if(j==1){System.out.print("   * *   ");}
  175.         if(j==2){System.out.print("  *   *  ");}
  176.         if(j==3){System.out.print(" *     * ");}
  177.         if(j==4){System.out.print("*       *");}
  178.     }
  179.     /*for printing z*/
  180.     public void z(int i,int j)
  181.     {
  182.         if(i==1){System.out.print("*********");}
  183.         if(i==2){System.out.print("       * ");}
  184.         if(i==3){System.out.print("      *  ");}
  185.         if(i==4){System.out.print("     *   ");}
  186.         if(i==5){System.out.print("    *    ");}
  187.         if(j==1){System.out.print("   *     ");}
  188.         if(j==2){System.out.print("  *      ");}
  189.         if(j==3){System.out.print(" *       ");}
  190.         if(j==4){System.out.print("*********");}
  191.     }
  192. }

Now i'm over here with this program you can check other programs for learning different things. You can download the code from here. and if have any thought or query about this program so feel free to comment. Have a nice day.