-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathStrong Password.java
More file actions
30 lines (27 loc) · 860 Bytes
/
Strong Password.java
File metadata and controls
30 lines (27 loc) · 860 Bytes
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
public static int minimumNumber(int n, String password) {
String spcl="!@#$%^&*()-+";
Set<Character>s=new HashSet();
for(int i=0;i<spcl.length();i++)
{
s.add(spcl.charAt(i));
}
boolean num=false;
boolean upper=false;
boolean lower=false;
boolean spclC=false;
for(int i=0;i<password.length();i++)
{
char ch=password.charAt(i);
if(ch>='0'&&ch<='9')num=true;
else if(ch>='a'&&ch<='z')lower=true;
else if( ch>='A'&&ch<='Z')upper=true;
else if(s.contains(ch)==true)spclC=true;
}
int d=0;
if(num==true)d++;
if(upper==true)d++;
if(lower==true)d++;
if(spclC==true)d++;
int ans=(int )Math.max(6-n,4-d);
return ans;
}