-
Notifications
You must be signed in to change notification settings - Fork 0
/
Passwordcheck.java
109 lines (85 loc) · 2.47 KB
/
Passwordcheck.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package passwordsecurity;
import java.util.Scanner;
public class pass {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.println("Username");
String un=scan.next();
String str=" ";
int flag=0,index=0,flag1=0,flag2=0,flag3=0,flag4=0,index1=0;
for(int i=0;i<un.length();i++){
if(un.charAt(i)=='@'){
flag=1;
index=i;
break;
}
}
for(int i=index;i<un.length();i++){
if(un.charAt(i)=='.'){
flag1=1;
index1=i;
break;
}
}
if(flag==1 && flag1==1){
for(int i=index+1;i<index1;i++){
str+=un.charAt(i);
}
}
if(flag==1 && flag1==1){
System.out.println("Hello"+str+" "+"user");
}
System.out.println("Password");
String pwd=scan.next();
if(pwd.length()>=8){
if(un!=pwd){
for(int i=0;i<pwd.length();i++){
int d=pwd.charAt(i);
if(d>=48 && d<=57){
flag2=1;
break;
}
}
for(int i=0;i<pwd.length();i++){
int d=pwd.charAt(i);
if(d<48 || d>57 && d<65 || d>91 && d<122){
flag3=1;
break;
}
}
int p=pwd.charAt(0);
if(p>=65 && p<=91){
flag4=1;
}
}
}
if (flag==1 && flag1==1 && flag2==1 && flag3==1 && flag4==1){
System.out.println("Welcome to our calculator");
System.out.println("Enter first number");
int fn=scan.nextInt();
System.out.println("Enter second number");
int sn=scan.nextInt();
System.out.println("Choose an operator");
String op=scan.next();
int ans=0;
switch(op.charAt(0)){
case '+':
ans=fn+sn;
break;
case '-':
ans=fn-sn;
break;
case '*':
ans=fn*sn;
break;
case '/':
ans=fn/sn;
break;
}
System.out.println("Answer = "+ans);
}
else{
System.out.println("This account does not exist");
}
}
}