title: Boolean help: Testing the parameters for a password JAVA
body: <h3>Task:</h3>
  <p>This program should check if an entered password is at least 8 characters long, one upper and lowercase letter, a number, and a special character.</p>
  <h3>Code:</h3>
  <pre><code>String password;
  boolean hasLength;
  boolean hasUppercase;
  boolean hasLowercase;
  boolean hasDigit;
  boolean hasSpecial;
  
  Scanner scan = new Scanner(System.in);
  /******************************************************************************
  *                             Inputs Section                                  *
  ******************************************************************************/
  System.out.println(&quot;A password must be at least 8 character long&quot;);
  System.out.println(&quot;And must contain:&quot;);
  System.out.println(&quot;-At least 1 number&quot;);
  System.out.println(&quot;-At least 1 uppercase letter&quot;);
  System.out.println(&quot;-At least 1 special character (!@#$%^&amp;*()_+)\n&quot;);
  System.out.print(&quot;Please enter your new password: &quot;);
  password = scan.nextLine();
  
  /******************************************************************************
  *                           Processing Section                              *
  ******************************************************************************/
  System.out.print(&quot;\n&quot;);
  System.out.println(&quot;Entered Password:\t &quot; + password);
  
  hasLength = password.length() &lt; 8; // parameters for length
  // for lower and uppercase characters
  hasUppercase = !password.equals(password.toUpperCase());
  hasLowercase = !password.equals(password.toLowerCase());
  hasDigit =  !password.matches(&quot;[0-9]&quot;);//checks for digits
  hasSpecial = !password.matches(&quot;[A-Za-z]*&quot;); //for anything not a letter in the ABC's
  
  
  // the following checks if any of the instances are false, of so prints the statement
  if(hasLength)
  {
      System.out.println(&quot;Verdict: Invalid, Must have at least 8 characters&quot;);
  }
  
  if(!hasUppercase)
  {
      System.out.println(&quot;Verdict: Invalid, Must have an uppercase Character&quot;);
  }
  if(!hasLowercase)
  {
      System.out.println(&quot;Verdict: Invalid, Must have a lowercase Character&quot;);
  }
  if(!hasDigit)
  {
      System.out.println(&quot;Verdict: Invalid, Must have a number&quot;);
  }
  if(!hasSpecial)
  {
      System.out.println(&quot;Verdict: Invalid, Must have a special character&quot;);
  }
  </code></pre>
  <p>If I input the password 'water' and I get:</p>
  <pre><code>Entered Password:    water
  Verdict: Invalid, Must have at least 8 characters
  Verdict: Invalid, Must have a lowercase Character
  Verdict: Invalid, Must have a special character
  </code></pre>