Two problems :
1. You are comaring strings using ==/!=. Don't. Compare strings using equals()
2. Strings are not booleans. When you write "|| joint ||", the compiler expects a boolean(true/false) value here. What do you want to express exactly ?
I assume you want to compare status with seperate and status with joint and status with head and status with single. I see two problems.
1. In Java, you cannot specify the code as you would in English: if status is not equal to seperate or joint or head or single. You need to code it as in English: if status is not equal to seperate and status is not equal to joint and status is not equal to head and status is not equal to single.
2. You should not use "==" when comparing two Strings. You should use the equals() method.
Please respond if you need more guidance.
Joined: Feb 24, 2011
Hey guys, thanks for the quick help.
As far as using equals(), I don't think we've been taught that in class. What I'm trying to accomplish here is, if the user inputs anything other than S, H, MJ, or MS, I want to have the program exit.
Problem is, it's difficult to compare strings, at least as far as I know how. I'm not sure how to use equals() at all.
As far as using equals(), I don't think we've been taught that in class.
You want to be number one in your class ? Then read this article. You'll know what strings are and how to compare them. You'll understand how == differs from equals(). You'll say to your classmates "what ? you haven't read that awesome Javaranch article yet ?". Go ahead and read it carefully.
What I'm trying to accomplish here is, if the user inputs anything other than S, H, MJ, or MS, I want to have the program exit.
Then you have to compare eachstring, the same way you did for "seperate". Also, think again about using ||. Are you sure you want to "or", instead of "and" ?