JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String password = input.nextLine();
// returns true value if there is 2 number and 2 special character from the following
Pattern pattern = Pattern.compile(".*(?=(.*[0-9]){2,}).*(?=(.*[#!@$%&*]){2,}).*");
Matcher matcher = pattern.matcher(password);
boolean strong = matcher.matches();
if(password.length() >= 7 && strong){
System.out.println("Strong");
}else{
System.out.println("Weak");
}
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run