i wrote a password check program: rules: length not less that 6 and not more than 1/ not all alphabets/ not all numbers/not alphabets ending with number 99
if i try the password CGI/a199 it works thought if i try 99 it puts out of bound. any suggestions? and if i type cmps200 at first it puts valid but if i type after example cgi it puts rule 1 and 2 violated.
import java.util.*;

When posting code, make sure you use the CODE tags to preserve formatting. Otherwise nobody will want to read it.

You should step through your program with a debugger (or at the very least, put in a ton of print statements) to figure out what's going wrong.

11-24-2010, 07:10 PM

lovelesh

You need to refactor your code. String class offers a lot of powerful methods which you are not using.
By using these methods you can reduce the number of lines in your code by atleast 50%. Try using them

Just for your reference:
- use endswith method for checking last two characters
- use Integer.parseInt to check if the string is integer only.
- In some of the methods you have declared unneccasary parameters

Could you post the complete error message. OutOfBound can be in many places, how we know that? Only the error message help us, or else we have to run your code and fix those. I'm lazy to do that, so do others.

11-25-2010, 09:54 AM

Vinod Mukundan

Hi Farhm,

As far as I noticed out of bound exception comes bcoz you are not reassigning the variable "len" ... so it contains the previous data(length of the previous value as in your case the first entered password) giving you the exception . Try adding