Results 1 to 6 of 6
Thread: If statement problem
- 11-27-2012, 07:34 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
If statement problem
Hello,
I have encountered a problem in which when I input "Eagle", and then "Eagle" as the answer it comes out as "Correct". However, when I input "Bear" and "Eagle" as the answer it still comes out as "Correct".
Could anyone tell me how to fix this? Thanks and waiting for a reply.
Here is the code;
String newWord = "";
String userWordGuess = "";
console.println("The new word?");
newWord = console.readLine();
console.println("Your guess?");
userWordGuess = console.readLine();
if (userWordGuess != newWord){
console.println("CORRECT");
} else {
console.println("INCORRECT");
}
}Last edited by maynn123; 11-27-2012 at 08:14 PM.
- 11-27-2012, 08:08 PM #2
Re: If statement problem
You're going to have to copy and paste your code as an SSCCE if you want somebody to help you with it.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 11-27-2012, 08:13 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,404
- Blog Entries
- 7
- Rep Power
- 17
Re: If statement problem
I'm psychic and through the cosmic mists of time and space I can see a == operator.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 11-28-2012, 09:39 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,466
- Rep Power
- 16
Re: If statement problem
Well, I can see a '!=' operator...:)
Please do not ask for code as refusal often offends.
- 11-28-2012, 09:48 AM #5
Re: If statement problem
And I see it prints "CORRECT" for !=
.gif)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 11-28-2012, 10:01 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,404
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
problem with if statement?
By cherrychives in forum New To JavaReplies: 6Last Post: 04-25-2012, 02:42 AM -
sql statement problem
By vincentcharrie in forum EclipseReplies: 5Last Post: 02-16-2012, 03:41 PM -
Problem with if statement
By SiX in forum New To JavaReplies: 8Last Post: 07-22-2011, 07:49 PM -
If-Else statement problem
By MomenT in forum New To JavaReplies: 9Last Post: 10-23-2008, 08:06 AM -
Please help me with this Problem Statement
By KMS in forum New To JavaReplies: 1Last Post: 09-22-2008, 08:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks