import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
String special = "~`!@#$%^&*()-_=+\\|[{]};:'\",<.>/?";
char ch;
boolean n = false;
boolean upperCharacter = false;
boolean lowerCharacter = false;
boolean specialLetter = false;
System.out.print("Enter a string: ");
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
for (int i = 0; i < input.length(); i++) {
ch = input.charAt(i);
if (Character.isDigit(ch)) {
n = true;
} else if (Character.isUpperCase(ch)) {
upperCharacter = true;
} else if (Character.isLowerCase(ch)) {
lowerCharacter = true;
} else if (special.contains(String.valueOf(ch))) {
specialLetter = true;
}
else{
System.out.print("Invalid Credentials");
}
}
return
n && upperCharacter && lowerCharacter && specialLetter;
}}
}
Comments
Leave a comment