密码强度验证,有小伙伴测试出问题我做了完善的(其实是标准正解啦)
import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
String password=scan.next();
boolean containAlpha=false;
boolean containLetter=false;
for(int i=0;i<password.length();i++){
char c=password.charAt(i);
if(c>='0'&&c<='9')
containAlpha=true;
else if(c>='a'&&c<='z'||c>='A'&&c<='Z')
containLetter=true;
}
if(password.length()>6&&containAlpha&&containLetter)
System.out.println("强");
else if(password.length()>6||(containLetter&&containAlpha))
System.out.println("中");
else if(password.length()<=6&&containAlpha&&!containLetter)
System.out.println("弱");
}
}