forked from PriyaGhosal/SkillWise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Email Validator
30 lines (24 loc) · 1.07 KB
/
Email Validator
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
import java.util.Scanner;
public class LoginPage {
public static void main(String[] args) {
// Create a scanner object for user input
Scanner scanner = new Scanner(System.in);
// Prompt the user to enter an email address
System.out.print("Enter your email address: ");
String email = scanner.nextLine();
// Validate the email address
if (EmailValidation.isValidEmail(email)) {
// If valid, prompt for password
System.out.print("Enter your password: ");
String password = scanner.nextLine();
// Simulate login (for demonstration purposes)
// In a real application, you would check the credentials against a database
System.out.println("Login successful for email: " + email);
} else {
// If invalid, print an error message
System.out.println("The email address \"" + email + "\" is invalid. Please enter a valid email.");
}
// Close the scanner to prevent resource leaks
scanner.close();
}
}