I am getting trouble with writing this program. the password:
must have a letter and digit
must be between the range of 6-10
must be in al oop(user cannot move on until it is correct.
plz help!!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I am getting trouble with writing this program. the password:
must have a letter and digit
must be between the range of 6-10
must be in al oop(user cannot move on until it is correct.
plz help!!
That's not how this works. This isn't a code service. Ask a specific question and post an SSCCE demonstrating where you're stuck.
How To Ask Questions The Smart Way
ok cool...the code is:
import javax.swing.*; public class Password2 { public static void main(String [] args) { int digit=0; int letter=0; String pw1=""; String pw2; int size = pw1.length(); do { pw1=JOptionPane.showInputDialog("enter password: "); size = pw1.length(); { for(int i=0;i<size;i++) { char ch=pw1.charAt(i); if(Character.isDigit(ch)) digit++; if(Character.isLetter(ch)) letter++; } } }while(!(size>=6 && size<=10 && digit>=1 && letter>=1));
everyting works good except i have to:
prompt user to enter password again to confirm it is correct and if the password does not match the first password entered the program suppose to loop.
Last edited by helloworld922; November 11th, 2010 at 03:15 AM.
Then I'd say you should check out your conditional statement. Add some print lines, or use a debugger, to figure out what's going on. What is the value of size, digit, and letter? Is that what you'd expect?
PS- When posting code, make sure you use the CODE tags to preserve formatting.
how do i use the code tag...solved the question but now i need it to stop the loop at 3 tries.
[code]CODE[/code] will display ashow do i use the code tagdbCODE