-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword.java
More file actions
30 lines (29 loc) · 1.04 KB
/
Password.java
File metadata and controls
30 lines (29 loc) · 1.04 KB
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
import java.util.Scanner;
public class Password {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a password : ");
String password = sc.nextLine();
int lowercaseCount = 0;
int uppercaseCount = 0;
int digitCount = 0;
int specialCharacterCount = 0;
int length = password.length();
for (int i = 0; i < length; i++) {
int ch = password.codePointAt(i);
if (ch >= 97 && ch <= 122)
lowercaseCount++;
else if (ch >= 65 && ch <= 90)
uppercaseCount++;
else if (ch >= 48 && ch <= 58)
digitCount++;
else
specialCharacterCount++;
}
System.out.println("Lowercases : " + lowercaseCount);
System.out.println("Uppercases : " + uppercaseCount);
System.out.println("Digits : " + digitCount);
System.out.println("Special Character : " + specialCharacterCount);
sc.close();
}
}