Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions