I have a homework assignment that requires me to write a program that asks for a password and checks to see if it is acceptable.
The requirements for a good password are as follows:
1. must be at least 6 characters
2. must have at least one uppercase letter
3. must have at least one lowercase letter
4. must have at least one digit
My program successfully compiles but it seems like it gets stuck in the loop when I try to run it and It can't get past the length test.
One problem that I see is that you don't reset upper, lower and digit back to false on each pass through the do/while loop. If the user entered a password with an upper but not a lower on the first attempt, upper would be set to true. If the second attempt had no upper case letter, upper is still set to true.
Thanks for the tip. I fixed that part. Can you see what would be causing the issue that gets it stuck in the loop at the length test? This is what happens when running it:
output: Enter a password
input: ggg
output: Error! your password must be at least 6 characters.
output: Enter a password
input: ggggggg
output: Enter a password
It will give the error message if the password is not long enough but other than that it's stuck in the loop and asks for a password over and over.
Thank you! The problem was that I forgot to include an error message for the other conditions so that's why it seemed like it was stuck. Sorry about that, I really should've been able to catch that myself.