I want the program to do 2 things:
- Check if the string(password input) contains both letters and numbers.
- Check if the password has atleast 8 characters.
Here is my code:
import java.util.*;
class howstrong
{
public static void main(String ar[])
{
String password;
int i;
int c=0;
Scanner in = new Scanner(System.in);
System.out.println("ENTER PASSWORD");
password = in.next();
if (password.length() <= 8)
{
for (i = 0; i <= password.length(); i++)
{
char x = password.charAt(i);
if (Character.isLetter(x))
{
if (Character.isDigit(x))
c = 1;
}
}
if (c == 1)
System.out.println("STRONG");
else
System.out.println("NOT STRONG");
}
else
System.out.println("HAVE AT LEAST 8 CHARACTERS");
}
}