ID and Password Verification (String)

package String;


import java.util.Scanner;


public class EmailPassVer {

public static void main(String[] args) {

Scanner sc= new Scanner(System.in);

System.out.println("Enter your mail");

String email=sc.next();

Boolean tf=isValid(email);

if(tf.equals(false)) {

System.out.println("not valid email");

}else {

System.out.println("Enter your password");

String pass=sc.next();

String eemail="bikas.shah1921@gmail.com";

String ppass="bikas123";

if(email.equals(eemail) && pass.equals(ppass)) {

System.out.println("Login Sucessfully");

}else if (email.equals(eemail)||pass.equals(ppass)) {

System.out.println("Email password not match");

}else if(email.isBlank()) {

System.out.println("email cannot be blank");

}else if(email.isEmpty()) {

System.out.println("email cannot be empty");

}else if(pass.isBlank()) {

System.out.println("pass cannot be blank");

}else if(pass.isEmpty()) {

System.out.println("pass cannot be empty");

}else if(email.equalsIgnoreCase(eemail)||pass.equalsIgnoreCase(ppass)) {

System.out.println("Login Successfully");

}else {

System.out.println("Wrong email and password");

}

}

sc.close();

}

static boolean isValid(String email) {

   String regex = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";

   return email.matches(regex);

}


}


Comments

Popular posts from this blog

A simple method using string to check whether the input password is correct or not

Java Program any letter to upper case Letter(JavaSWING) ActionListener

JAVA(String Buffer and String Builder