Area in the grey can not be edited. Meaning line 1(or beinging of code)-line6 and from line 8 - 8 (or end of code). Code must be inbetween the two blocks of Java Code. Note: Character.isLetter() returns true if a character is a letter, and false otherwise. Ex: Character.isLetter('a') returns true. Character.isLetter('8') returns false.
Area in the grey can not be edited. Meaning line 1(or beinging of code)-line6 and from line 8 - 8 (or end of code). Code must be inbetween the two blocks of Java Code.
Note: Character.isLetter() returns true if a character is a letter, and false otherwise. Ex: Character.isLetter('a') returns true. Character.isLetter('8') returns false.
1. Import Scanner class
2. Create a Scanner object (scnr) to read input
3. Declare a String variable (secretStr)
4. Read input from the user and store it in secretStr
5. Close the Scanner object
6. Initialize letterCount to 0
7. For each character 'c' in secretStr:
a. If 'c' is a letter, increment letterCount by 1
8. Initialize goodPasswd based on the condition (letterCount < 5) && (length of secretStr > 5)
9. If goodPasswd is true, print "Valid"
Else, print "Invalid"
Step by step
Solved in 3 steps with 1 images