title: Password Generation in java with regular expression
body: <p>IDFC, a leading Bank sector offers online shopping to their customers, To avail this offer, the customer will have to generate a security code, for the first time usage of his card to purchase online.</p>
  <p>Hint to generate a security code is as follows :</p>
  <p>1.Minimum of 8 Characters</p>
  <p>2.Must contain atleast one uppercase, one lowercase and one special character.</p>
  <ol start="3">
  <li>Only the special characters @,*,#  are allowed.</li>
  </ol>
  <p>The code fails to meet the criteria, will response with an error message as shown in the sample output.</p>
  <p>Develop an application to implement this scenario.</p>
  <p>Write a public class Main with the main method.  Write the code to get the input, validate and print the output.</p>
  <p><strong>Sample Input 1:</strong></p>
  <p>Generate your Security Code</p>
  <p>Ab12345@</p>
  <p><strong>Sample Output 1:</strong></p>
  <p>Security Code Generated Successfully</p>
  <p><strong>Sample Input 2:</strong></p>
  <p>Generate your Security Code</p>
  <p>S1995p123</p>
  <p><strong>Sample Output 2:</strong></p>
  <p>Invalid Security Code, Try Again!</p>
  <p><strong>I was able to come up with a code which basically passes all the visible condition, but failing to test one. Not really sure where I am going wrong.</strong></p>
  <pre><code>import java.util.*;
  import java.util.regex.*;
  
  class Main{
          public static void main(String a[]){
          Scanner sc = new Scanner(System.in);
          System.out.println(&quot;Generate your Security Code&quot;);
          String code = sc.next();
          String regex = &quot;[A-Za-z0-9@*#]{8}&quot;;
          Pattern p = Pattern.compile(regex);
          Matcher m = p.matcher(code);
          boolean matchFound = m.find();
          if(matchFound)
          System.out.println(&quot;Security Code Generated Successfully&quot;);
          else
          System.out.println(&quot;Invalid Security Code, Try Again!&quot;);
      }
  }
  </code></pre>
  <pre><code>Evaluation Result:
  Proposed grade: 75 / 100
  Result Description
  Failed tests
  Test 3: Invalid Password
  
  Test 1: Valid Password
  
  Summary of tests
   
  *Note: All the test cases might not have same weightage
   
  4 tests run/ 3 tests passed 
  </code></pre>