The program is a game where the user has to guess the magical number to win. I'm new to java, and I am still learning. When I type in 53, it just ask the question agains instead of displaying the output. I'm sure it's a simple error that I'm just not catching. Thanks!
import javax.swing.JOptionPane;
class NumberFrom1To100 {
public static void main(String[] args) {
boolean stillplaying = true;
double answer = 53;
double userAnswer;
String userInput;
while (stillplaying == true) {
userInput = JOptionPane.showInputDialog("Guess a number between 1 and 100.");
userAnswer = Double.parseDouble(userInput);
while (userAnswer != 53) {
if (userAnswer < 53) {
JOptionPane.showMessageDialog(null, "You picked a number LESS than the mystery number. Try again.");
break;
} else if (userAnswer > 53) {
JOptionPane.showMessageDialog(null, "You picked a number GREATER than the mystery number. Try again.");
break;
} else if (userAnswer == 53) {
JOptionPane.showMessageDialog(null, "Congratulations! You just won 5 brownie points!");
break;
}
}
}
/* System.exit(0); */
}
}