- My Forums
- Tiger Rant
- LSU Recruiting
- SEC Rant
- Saints Talk
- Pelicans Talk
- More Sports Board
- Fantasy Sports
- Golf Board
- Soccer Board
- O-T Lounge
- Tech Board
- Home/Garden Board
- Outdoor Board
- Health/Fitness Board
- Movie/TV Board
- Book Board
- Music Board
- Political Talk
- Money Talk
- Fark Board
- Gaming Board
- Travel Board
- Food/Drink Board
- Ticket Exchange
- TD Help Board
Customize My Forums- View All Forums
- Show Left Links
- Topic Sort Options
- Trending Topics
- Recent Topics
- Active Topics
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 Pectus
Posted on 12/14/13 at 9:55 am to Pectus
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()
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
Popular
Back to top
Follow TigerDroppings for LSU Football News