Results 1 to 4 of 4
- 12-10-2009, 10:11 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 7
- Rep Power
- 0
exiting a while loop with a string
Hello all...I seem to be having some trouble exiting a while loop with a string. This feels really embarrassing but here is my code:
private static String strDifficulty()
{
String strDif;
strDif = JOptionPane.showInputDialog("What difficulty setting would you like? Hard or easy?");
while (!strDif.equalsIgnoreCase("easy") || !strDif.equalsIgnoreCase("hard"));
{
strDif = JOptionPane.showInputDialog("Please enter in either 'hard' or 'easy'. Thank you.");
}
return strDif;
}
}
unfortunately I'm stuck in a while loop. any help would be greatly appreciated! Thanks all :).
- 12-10-2009, 10:16 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Pick a number between 1 and 1000 (but don't say what it is).
The number you picked was either not equal to 42 or it was not equal to 666.
Perhaps you don't really mean "!equals()||!equals()" in the condition of your while loop.
- 12-10-2009, 10:27 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 7
- Rep Power
- 0
lol, thanks. I think i should take a logic course.
- 12-10-2009, 10:38 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
You're welcome. It's usually enough to say these things out loud to pick up what the problem is. But if you do want the formal treatment of how not "distributes" over and and or, check out De Morgan's laws.
Similar Threads
-
Exiting on menuSelected action
By benra in forum New To JavaReplies: 8Last Post: 10-13-2009, 04:58 PM -
String and while loop
By Exception in forum Java AppletsReplies: 5Last Post: 09-24-2009, 12:32 PM -
Using string to terminate loop
By mrblippy in forum New To JavaReplies: 3Last Post: 04-23-2009, 06:16 AM -
Entering string in a loop with method
By Konex in forum New To JavaReplies: 3Last Post: 03-01-2009, 07:33 AM -
terminating a while loop with a string
By tkdvipers in forum New To JavaReplies: 3Last Post: 07-09-2007, 11:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks