Started By
Message

re: Help me with my nested if statements in java (self-learning Novice)

Posted on 12/14/13 at 9:55 am to
Posted by Eternalmajin
Member since Jun 2008
13082 posts
Posted on 12/14/13 at 9:55 am to
What you can do in situations like this is, right before the:
if(gender == female && married = yes)

block, print out the values of gender, female, married, and yes. This will let you see, from the program's perspective, what those values are and make sure they match up.

If they match up, it may be an issue of comparing strings. I'm not sure if java has different functions for strings like this or not, but I know C had strcmp() for comparing them.

Just by looking at it, I have a feeling the program is seeing a difference between declaring a variable as a string and reading one in from keyboard.next()
This post was edited on 12/14/13 at 10:00 am
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on Twitter, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookTwitterInstagram