Question: Problem Description: Search d and file names for text Some websites impose certain rules for passwords. Suppose password rules are as follows: 1. A password

 Problem Description: Search d and file names for text Some websites

Problem Description: Search d and file names for text Some websites impose certain rules for passwords. Suppose password rules are as follows: 1. A password must have at least eight characters. 2. A password consists of only letters and digits. 3. A password must contain at least two digits. Write a program with class name CheckPassword that prompts the user to enter a password and displays Valid password if the rules are followed or Invalid password otherwise. Create three methods (headers given below) to check the three rules. 5. public static boolean AtLeast8(String p) public static boolean LetterOrDigt Stringp) public static boolean AtLeast2Digits(String p) Create a method LetterOrDigit outside the main method with the header provided in the problem description. The password is passed to the string variable p in this method. Inside the method do the followings. For example, method AtLeast8 will return true if there are at least eight characters in the password otherwise it will retum false. i) Create a loop that checks whether each character in p is a letter or a digit. To Character.isLetterOrDigit(p.charAt(index)). The method isLetterOrDigit returns true if p.charAt(index) is a letter or digit. check this use in-built methods Here are four sample runs: Sample 1 Enter your password: My password18 Invalid password ii) Ifa character is not found to be a letter or digit then return false inside the loop, otherwise return true outside the loop Sample 2: Enter your password: pass18 Invalid password Sample 3 Enter your password: password Invalid password Sample 4: Enter your password: passwordi8 Valid password You can use the following steps in your code: System.out.print("Enter your password

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 Databases Questions!