title: Incorrect Output Error by Rachit Bhargava
body: <p>I have made a program for question:</p>
  
  <p>Write a program in Java to input first name, middle name and last name. Validate the digital signature that contains first name and last name. If the signature doesn't contain any of these, print "Invalid Signature". Also, print his full name in a single line.</p>
  
  <p>The programs is:</p>
  
  <pre><code>// Write a program in Java to input first name, middle name and last name. Validate the digital signature that contains first name and last name. If the signature doesn't contain any of these, print "Invalid Signature". Also, print his full name in a single line.
  import java.io.*;
  public class TaskPE_2
  {
      public static void main(String args[])throws IOException, StringIndexOutOfBoundsException
      {
          BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Please enter your full name");
          String name=read.readLine();
          System.out.println("Please enter your digital signature");
          String signature=read.readLine();
          String fname="", mname="", lname="";
          char n='0';
          name=name.trim();
          String dummy=name;
          dummy+=" ";
          while(n!=' ')
          {
              n=dummy.charAt(0);
              if(n!=' ')
                  fname+=n;
              dummy=dummy.substring(1);
          }
          n='0';
          while(n!=' ')
          {
              n=dummy.charAt(0);
              if(n!=' ')
                  mname+=n;
              dummy=dummy.substring(1);
          }
          n='0';
          while(n!=' ')
          {
              n=dummy.charAt(0);
              if(n!=' ')
                  lname+=n;
              dummy=dummy.substring(1);
          }
          int l=name.length();
          int namef=0, namel=0;
          dummy=name;
          int lf=fname.length(), ll=lname.length();
          int i;
          for(i=0; i&lt;=(l-(lf+1)); i++)
              if((signature.substring(i, (i+(lf-1)))).equals(fname))
                  namef=1;
          if(namef==1)
              System.out.println("F PASSED");
          for(i=0; i&lt;=(l-(ll+1)); i++)
              if((signature.substring(i, (i+(ll-1)))).equals(lname))
                  namel=1;
          if(namel==1)
              System.out.println("L PASSED");
          if(namef==1&amp;&amp;namel==1)
              System.out.println("Your entered digital signature is valid");
          else
              System.out.println("Invalid digital signature entered");
          System.out.println("Your full name is "+fname+" "+mname+" "+lname+".");
      }
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Please enter your full name
  Rachit R Bhargava
  Please enter your digital signature
  Rachit Bhargava
  Invalid digital signature entered
  Your full name is Rachit R Bhargava.
  </code></pre>
  
  <p>Please Note: I am using BlueJ 3.1.1 to make my Java programs. Any help would be appreciated.</p>
  
  <p>Waiting for someone's help...</p>