Results 1 to 8 of 8
Thread: Couple questions
- 03-22-2013, 06:55 PM #1
Member
- Join Date
- Mar 2013
- Posts
- 4
- Rep Power
- 0
Couple questions
How do I use if and else if to play a game of rock paper scissors?
JOptionPane.showInputDialog("Enter rock, paper, or scissors");
JOptionPane.showInputDialog("Enter rock, paper, or scissors");
Now after this I have to write the if statements but dont understand how to do so to make it work. So far one person enters one of the options then hits okay then the other person would have to do the same then hit okay. I then need the program to figure out who wins and pops up another Dialog box telling the winner.
My next problem is this (code below). I wrote code using if statements to order numbers in numerical order but the program doesnt run any of my JOptionPanes even though its not giving me any errors or anything. I understand there are other possible ways of ordering numbers but this is the way I have to do it right now. What's my problem?
Thanks!
if (number1 > number2)
if (number2 > number3)
JOptionPane.showMessageDialog(null," "+ number1 + "," + number2 + "," + number3);
else
if (number1 > number2)
if (number2 < number3)
JOptionPane.showMessageDialog(null," "+ number1 + "," + number3 + "," + number2);
else
if (number1 < number2)
if (number2 < number3)
JOptionPane.showMessageDialog(null," "+ number3 + "," + number2 + "," + number1);
else
if (number1 > number2)
if (number2 < number3)
if (number1 < number3)
JOptionPane.showMessageDialog(null," "+ number3 + "," + number1 + "," + number2);
else
if (number1 < number2)
if (number2 > number3)
if (number1 > number3)
JOptionPane.showMessageDialog(null," "+ number2 + "," + number1 + "," + number3);
else
if (number1 < number2)
if (number2 > number3)
if (number1 < number3)
JOptionPane.showMessageDialog(null," "+ number2 + "," + number3 + "," + number1);Last edited by L2Code; 03-22-2013 at 07:27 PM.
- 03-22-2013, 07:35 PM #2
Re: Couple questions
My first advice is to use curly brackets and indentation to organize your if/else blocks better.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 03-22-2013, 07:45 PM #3
Member
- Join Date
- Mar 2013
- Posts
- 4
- Rep Power
- 0
- 03-22-2013, 07:49 PM #4
Re: Couple questions
Crossposted: Help my if statements!
I really can't help you until you fix your formatting.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 03-22-2013, 08:32 PM #5
Member
- Join Date
- Mar 2013
- Posts
- 4
- Rep Power
- 0
- 03-22-2013, 08:33 PM #6
Re: Couple questions
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 03-22-2013, 08:46 PM #7
Member
- Join Date
- Mar 2013
- Posts
- 4
- Rep Power
- 0
Re: Couple questions
Is it suppose to work without the "else" in there? Because I tried to just delete them after I put the brackets in there because of the syntax error that was coming up and now it works ( or so it seems so far).
- 03-22-2013, 09:54 PM #8
Re: Couple questions
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
Couple of Generics questions
By UAF in forum Advanced JavaReplies: 3Last Post: 03-31-2011, 09:37 AM -
Couple questions about Java
By theadolescent in forum New To JavaReplies: 3Last Post: 05-19-2010, 02:13 AM -
Couple Questions on Thread
By Lil_Aziz1 in forum Threads and SynchronizationReplies: 5Last Post: 01-06-2010, 02:02 PM -
Couple of questions regarding threading
By exernet in forum New To JavaReplies: 1Last Post: 12-15-2009, 12:23 PM -
Couple of newbie questions
By ananasman in forum New To JavaReplies: 11Last Post: 11-20-2008, 11:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks