title: Creating a program that asks for a password and checks if its correct or not
body: <p>this is some practice i am doing for my midterm tomorrow. I cant seem to find the problem with my code, this is the question:</p>
  
  <blockquote>
    <p>Having a secure password is a very important practice, when much of our information
        is stored online. Write a program that validates a new password, following these
        rules:</p>
    
    <p>• The password must be at least 8 characters long.</p>
    
    <p>• The password must have at least one uppercase and one lowercase letter</p>
    
    <p>• The password must have at least one digit.</p>
    
    <p>Write a program that asks for a password, then asks again to confirm it. If the
        passwords don’t match or the rules are not fulfilled, prompt again. Your program
        should include a method that checks whether a password is valid.</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.util.Scanner;
  
  /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  
  /**
   *
   * @author HP Laptop
   */
  public class PasswordValidation {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          Scanner in = new Scanner(System.in);
          System.out.print("Please enter password : ");
          String password = in.nextLine();
          System.out.print("Please re-enter the password to confirm : ");
          String confirm = in.nextLine();
          boolean condition;
          condition = isValid(password);
          while (!password.equals(confirm) &amp;&amp; (!condition)) {
              System.out.println("The password is invalid");
              System.out.print("Please enter the password again : ");
              String Password = in.nextLine();
              System.out.print("Please re-enter the password to confirm : ");
              String Confirm = in.nextLine();
  
  
          }
          if (isValid(password)) {
              System.out.println("The password is valid");
          /*} else {
              System.out.println("The password is not valid");
              System.out.print("Please enter the password again : ");
              String Password = in.nextLine();
              System.out.print("Please re-enter the password to confirm : ");
              String Confirm = in.nextLine();
          }*/
      }
      }
  
      public static boolean isValid(String password) {
  
          if (password.length() &lt; 8) {
              return false;
          } else {
  
          for (int i = 0; i &lt; password.length(); i++) {
              if (Character.isUpperCase(password.charAt(i))) {
              }
          }
  
  
          for (int b = 0; b &lt; password.length(); b++) {
              if (Character.isLowerCase(password.charAt(b))) {
              }
          }
  
          for (int c = 0; c &lt; password.length(); c++) {
              if (Character.isDigit(password.charAt(c))) {
              }
  
          }
  
          return true;
  
  
      }
  }
  }
  </code></pre>
  
  <p>Error is:</p>
  
  <p>I enter a name less than 8 digits and it would say its valid when its not, also when its all valid and right, it doesn't print that its valid.</p>