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);