I am trying to create a java password code where the password is at least 6 characters Long, at least 1 UPPERCASE, & at least 1 lowercase & at least 1 Digit.Here is an example: Passw3
Can someone help me because it is not working. Here is the code
private static boolean isValid(String custNumber)
{
boolean goodSoFar = true;
int index = 0;
// Test if string the correct length
if (custNumber.length() !=6)
goodSoFar = false;
// Test if string has at least one UPPER case
while (goodSoFar && index < 6)
{
if (!Character.isUpperCase(custNumber.charAt(index)))
goodSoFar = false;
index++;
}
//Test if string has at least one lower case
while (goodSoFar && index < 6)
{
if (!Character.isLowerCase(custNumber.charAt(index)))
goodSoFar = false;
index++;
}
//Test if string has at least one Digit
while (goodSoFar && index < 6)
{
if (!Character.isDigit(custNumber.charAt(index)))
goodSoFar = false;
index++;
}
return goodSoFar;
}
}