I have refined my code but now i need help on trying to get the program to prompt the user to re-enter the password when it does not meet the specified criteria. Also after i enter a valid password it prompts me to re-enter the it adds another entry line and if i either press the enter key or enter the same password again it then accepts it. Could some one help. Here is my code:
import java.util.Scanner;
public class Password2
{
public static void main(String[] args)
{
char aChar;
int length;
String aString;
String password;
Scanner input = new Scanner(System.in);
System.out.println("Welcome please enter your password.>>");
aString = input.nextLine();
aChar = aString.charAt(0);
length = aString.length();
Character.isLetter(aChar);
Character.isDigit(aChar);
Scanner input1 = new Scanner(System.in);
System.out.println("Re-enter to confirm Password");
password = input1.nextLine();
if(length <6 || length >10 && aChar <1)
System.out.println("Password must contain at least 6-10 characters.");
if(password.equals(aString))
{
System.out.println("Password accepted.");
}
}
}