File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ public class PasswordStrength {
2+ public static void main (final String ar []) {
3+ String password = AbraKadabra1287832FQENi ;
4+
5+ boolean hasLetter = false ;
6+ boolean hasDigit = false ;
7+ boolean hasUpperCase = false ;
8+ boolean hasLowerCase = false ;
9+
10+ if (password .length () >= 8 ) {
11+ for (int i = 0 ; i < password .length (); i ++) {
12+ char x = password .charAt (i );
13+ if (Character .isLetter (x )) {
14+ if (Character .isUpperCase (x )){
15+
16+ hasUpperCase = true ;
17+
18+ }else if (Character .isLowerCase (x )){
19+
20+ hasLowerCase = true ;
21+ }
22+
23+ hasLetter = true ;
24+ }
25+
26+ else if (Character .isDigit (x )) {
27+
28+ hasDigit = true ;
29+ }
30+
31+ // no need to check further, break the loop
32+ if (hasLetter && hasDigit && hasUpperCase && hasLowerCase ){
33+
34+ break ;
35+ }
36+
37+ }
38+ if (hasLetter && hasDigit && hasUpperCase && hasLowerCase ) {
39+ System .out .println ("STRONG" );
40+ } else {
41+ System .out .println ("NOT STRONG" );
42+ }
43+ } else {
44+ System .out .println ("HAVE AT LEAST 8 CHARACTERS" );
45+ }
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments