// if else较多 大家是否有可优化的地方? import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNext()) { // 注意 while 处理多个 case // 密码长度 4 5-7 8 // 字母 // 数字 0 1 >1 // 符号 0 1 >1 // 奖励 取最大奖励 // 累加得到最后的评分 String pwd = in.next(); int sumScore = 0; boolean hasLowLetter = false; boolean hasUpperLetter = false; int numberSum = 0; int otherSum = 0; int length = pwd.length(); if (length <= 4) sumScore += 5; else if (length >= 5 && length <= 7) sumScore += 10; else if (length >= 8) sumScore += 25; for (int i = 0; i < pwd.length(); i++) { char value = pwd.charAt(i); if (Character.isDigit(value)) { numberSum++; } else if (Character.isUpperCase(value)) { hasUpperLetter = true; } else if (Character.isLowerCase(value)) { hasLowLetter = true; } else { otherSum++; } } // 积分 if (numberSum == 1) sumScore += 10; else if (numberSum > 1) sumScore += 20; if (hasUpperLetter && hasLowLetter) sumScore += 20; else if (hasUpperLetter || hasLowLetter) sumScore += 10; if (otherSum == 1) sumScore += 10; else if (otherSum > 1) sumScore += 25; // 奖励 if (hasUpperLetter && hasLowLetter && numberSum >= 1 && otherSum >= 1) sumScore += 5; else if ((hasUpperLetter || hasLowLetter) && numberSum >= 1 && otherSum >= 1) sumScore += 3; else if ((!hasUpperLetter && !hasLowLetter) && numberSum >= 1 && otherSum >= 1) sumScore += 2; if (sumScore >= 0 && sumScore < 25) { System.out.println("VERY_WEAK"); } else if (sumScore >= 25 && sumScore < 50) { System.out.println("WEAK"); } else if (sumScore >= 50 && sumScore < 60) { System.out.println("AVERAGE"); } else if (sumScore >= 60 && sumScore < 70) { System.out.println("STRONG"); } else if (sumScore >= 70 && sumScore < 80) { System.out.println("VERY_STRONG"); } else if (sumScore >= 80 && sumScore < 90) { System.out.println("SECURE"); } else { System.out.println("VERY_SECURE"); } } } }