You need to loop through the array of valid names testing each one against the entered name. If you find a match you can stop searching. If you reach the end of the loop and you haven't found a match then the name is invalid.
Compare Strings by using the String equals method.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Yes you do, you have at least 2 in your code already.
Around line 29 you try to compare namesEntered with the whole validNames array, but you should just compare with the i'th element of that array.
And note my previous about comparing Strings.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
@Katana.
Please observe the rules for DaniWeb. Do not give the O/P a coded solution to his problem - that will teach him nothing, except how to cheat at homework.
If you want to help, give him some guidance so he can learn to use the reference material, and will remember what he has learned.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073