-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsername_Password_check.java
44 lines (43 loc) · 1.12 KB
/
Username_Password_check.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
//Read description for question//
import java.util.*;
class Main
{
public static boolean checkUser(String ss)
{
if(!(ss.length()>=8&&ss.length()<=32)){
return false;}
else
{
if(!(Character.isLetter(ss.charAt(0))))
return false;
else{
for(int i=0;i<ss.length();i++)
{
if(!(Character.isLetter(ss.charAt(i))||Character.isDigit(ss.charAt(i))||ss.charAt(i)=='_'))
return false;
}
}}
return true;
}
public static boolean checkPass(String ss)
{
if(ss.equals("admin123")||ss.equals("VITadmin!")||ss.equals("StudScope153*"))
return true;
else
return false;
}
public static void main(String s[])
{
Scanner obj=new Scanner(System.in);
String s1=obj.nextLine();
String s2=obj.nextLine();
if(checkUser(s1)){
if(checkPass(s2))
System.out.println("Welcome,"+s1);
else
System.out.println("Wrong Password");
}
else
System.out.println("Invalid Username");
}
}