-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword validity.java
More file actions
32 lines (29 loc) · 876 Bytes
/
Password validity.java
File metadata and controls
32 lines (29 loc) · 876 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
31
32
//To check if password matches or not
import java.util.*;
class Password {
public static void main(String a[]) {
int i, flag = 0;
String s2 = "Jia2005";
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Password");
String s1 = sc.next();
int n = s2.length();
char[] a1 = new char[n];
char[] a2 = new char[n];
a1 = s1.toCharArray();
a2 = s2.toCharArray();
System.out.println("*******");
for(i = 0; i < n - i; i++) {
if(a1[i] == a2[i]) {
continue;
} else {
flag = 1;
break;
}
}
if (flag == 0)
System.out.println("Password entered is correct");
else
System.out.println("Password entered is incorrect");
}
}