-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword Checker
More file actions
95 lines (79 loc) · 2.11 KB
/
Password Checker
File metadata and controls
95 lines (79 loc) · 2.11 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
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
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int count=0;
int count1=0;
int count2=0;
int count3=0;
char[] ar=s.toCharArray();
for(int i=0;i<ar.length;i++)
{
if (Character.isDigit(ar[i]))
{
count++;
}
else if (Character.isUpperCase(ar[i]))
{
count2++;
}
else if(ar[i]==' ' || ar[i]=='/')
{
count3++;
}
}
if (!Character.isDigit(s.charAt(0)) && ar.length>=4 && count>=1 && count2>=1 && count3==0)
{
System.out.println(1);
}
else
{
System.out.println(0);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int count=0;
int count1=0;
boolean valid=true;
if(Character.isDigit(s.charAt(0)) || s.length()<4)
{
valid=false;
}
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
if(Character.isDigit(ch))
{
count++;
}
else if(Character.isUpperCase(ch))
{
count1++;
}
else if(ch==' ' && ch=='/')
{
valid=false;
break;
}
}
if(valid && count>=1 && count1>=1)
{
System.out.println(1);
}
else
{
System.out.println(0);
}
}
}