aspose file tools*
The moose likes Beginning Java and the fly likes New to this stuff Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "New to this stuff" Watch "New to this stuff" New topic
Author

New to this stuff

Thomas Kelley
Greenhorn

Joined: Mar 14, 2012
Posts: 2
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

Joined: Apr 06, 2010
Posts: 4467
    
    8

Hi Thomas. Welcome to The Ranch!

Have a closer look at these two lines:

In particular, look at the "Y"...
Thomas Kelley
Greenhorn

Joined: Mar 14, 2012
Posts: 2
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
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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

Joined: Mar 13, 2009
Posts: 492

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


"If the facts don't fit the theory, get new facts" --Albert Einstein
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8244
    
  23

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to this stuff