Question: /*Write an application that prompts the user for a password that contains* at least two uppercase letters, at least three lowercase letters, * and at

/*Write an application that prompts the user for a password that contains* at least two uppercase letters, at least three lowercase letters, * and at least one digit. Continuously reprompt the user until a valid * password is entered. Display a message indicating whether the password * is valid; if not, display the reason the password is not valid. * Save the file as ValidatePassword.java*/import java.util.*;public class ValidatePasswordA{public static void main(String[] args){// Declare variablesString aString;int stringLength;final int NUM_UPPER_LETTERS = 2;final int NUM_LOWER_LETTERS = 3;final int NUM_DIGITS = 1;// counters for all the checksint upperCount = 0;int lowerCount = 0;int digitCount = 0;Scanner in = new Scanner(System.in);// loop until password id entered correctlywhile (upperCount < NUM_UPPER_LETTERS || lowerCount < NUM_LOWER_LETTERS || digitCount < NUM_DIGITS) {System.out.print("Enter a string >> ");// get password entered and the length of passwordaString = in.nextLine();stringLength = aString.length();// use for loop to cycle through password characters and update the countersfor(int i = 0; i < stringLength; i++){char ch = aString.charAt(i);if(Character.isUpperCase(ch))upperCount++;elseif(Character.isLowerCase(ch))lowerCount++;elseif(Character.isDigit(ch))digitCount++;}// Now check the counters to determine if the meet the requirements and print to consoleif(upperCount >= NUM_UPPER_LETTERS && lowerCount >= NUM_LOWER_LETTERS && digitCount >= NUM_DIGITS)System.out.println("Valid password");else{System.out.println("The password did not have enough of the foll

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!