Employee ID Validation
Global Info Technologies has approached you to develop an application to maintain the work details of their employees.
Imagine you are developing the login module. In that module,you will have to validate the id with the format given from the client.
The format is "GBL/001/0417", here the first three letters are standard. Create a class UserMain and implement the functionalities which are required.
Sample Input 1:
Enter your ID
GBL/020/0715
Sample Output 1:
Login success
Sample Input 2:
Enter your ID
ABC/120/0215
Sample Output 2:
Incorrect ID
RépondreSupprimerimport java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class UserMain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String id;
Pattern pattern = Pattern.compile("^GBL/\\d{3}/\\d{4}$");
System.out.println("Enter your ID");
id = scanner.next();
Matcher matcher = pattern.matcher(id);
if (matcher.matches()) {
System.out.println("Login success");
} else {
System.out.println("Incorrect ID");
}
}
}