• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another Password Validation Issue  RSS feed

 
Rachel Green
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write a program that validates a user's password. The requirements are:
• The password must be at least 8 characters long.
• The password must have at least one uppercase and one lowercase letter
• The password must have at least one digit.
Ask for a password, then ask again to confirm it. If the passwords don’t match or the rules are not fulfilled, prompt again. Your program should include a method that checks whether a password is valid.

I've been working on this for what seems like weeks and this is what I have so far. Right now, it doesn't seem to care what type password, as long as you enter it twice. Can anyone point me in the right direction? I'm planning on using variables for things like password length instead of hard coding it but I'm just focused on getting the app to run correctly first.


 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The body of your if() statement is empty. What do you want it to do?
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only need one for() loop and put your if()s inside it. Probably want to use "else  if()" because a character can't be both upper case and lowercase. you should be able to return prior to reaching the end of the password if it is valid, as soon as you've found at least one each of upper, lower, and digit, then you can return true;
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!