• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to this stuff

 
Thomas Kelley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I am new to this forum.. and somewhat new to java ..
I have this program that I am running and for some reason it is missing the first part of it.
it odes not ask for the age sex, voter party or who is voted for.
can someone please help me out with this.

Thank you
tom

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas. Welcome to The Ranch!

Have a closer look at these two lines:

In particular, look at the "Y"...
 
Thomas Kelley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help..
that worked..

but its not keeping trak of the the Male or fenale tally or the votes for Santorum Romney or paul.. any thoughts?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you are comparing the contents of two strings, don't use the == operator. That just checks whether its operands are the same String object, which isn't helpful because two different String objects can contain the same text.

You already knew to use the equals() method elsewhere. Use it everywhere you compare two String objects.
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The male or female tally is the same issue that you were having with "yes" vs "Yes",

you prompt the user to enter their sex:



Note "Male" or "Female" above

Then you test the sex condition using:



I think what you actually want to use is that way no matter what case you enter: "male", "Male", "mAlE", or "MALE" it will still return true.

Hunter
 
Winston Gutkowski
Bartender
Pie
Posts: 10508
64
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas Kelley wrote:can someone please help me out with this.

I think everybody else has pretty much told you the procedural problems, but the basic problem with your program to me is that it is procedural. Java is an Object (or, if you like, Class) oriented language, and Strings usually make bad substitutes for other classes.

My tip: Have a think about creating Party and Sex classes (no snickering in the back row).

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic