[Solved] How to check if there are 2 upper case letters, 3 lower case letters, and 1 number in JAVA


This looks like a homework question so I won’t solve it directly. However here are some steps you could take:

  • Create a method to validate the input (public static boolean isValid(String str))

  • Convert the String to a character Array. (There’s a method for that!)

  • Iterate over the letters and keep track of how many upper and lower case letters there are and how many digits there are. (Using Character.isDigit(), Character.isUpperCase() and Character.isLowerCase())

  • If all the requirements are met, return true. Return false otherwise.

0

solved How to check if there are 2 upper case letters, 3 lower case letters, and 1 number in JAVA