Write a Java program that can check the validity of a password.
- While loops
Write an application that
- Asks the user to enter the following case sensitive information:
- their first name
- last name
- password. A password can have letters, numbers, or other characters.
- Checks to see if their password is valid. A password is invalid if:
- It is less than 8 characters long.
- It contains their first name, last name or user name.
- Ignore the case when checking.
- If the password fails, ask the user to choose another password until they enter a valid password.
- Output all values upon a successful password choice.
Test the program with
- passwords less than 8 characters
- passwords containing the first. last and user names.
- passwords with numbers as well as characters
- Make sure your output makes sense to someone running the program.
- Use a different string variable for each item (first name, last name, …).
- Only ignore case when checking validity. Don’t just drop the case when scanning them in.
- The following string methods will help.
- string.length() returns the length of the string.
- string1.contains(string2) returns a boolean if the string1 contains string2 in it.
- string.toLowerCase() returns a lower case version of the string.
Edhesive Term 1
Lesson 17: While loops
Lesson 19: While loops with modular
Lesson 20: While loops with flag