-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPasswordValidator.java
41 lines (37 loc) · 1.04 KB
/
PasswordValidator.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
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
import java.util.regex.*;
public class PasswordValidator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String password = input.nextLine();
int val = 0;
int LenOfPaswd = password.length();
boolean num = Pattern.matches("(.*)[0-9]+(.*)", password);
boolean SpecialChar = Pattern.matches("(.*)[!@#$%&*]+(.*)", password);
System.out.println(num+" "+SpecialChar);
while (true) {
if (LenOfPaswd < 7) {
val = -1;
break;
}
else if(!(num)) {
val = -1;
break;
}
else if (!(SpecialChar)) {
val = -1;
break;
}
else {
val = 0;
break;
}
}
if (val == 0) {
System.out.println("Strong");
}
else {
System.out.println("Weak");
}
}
}