我正在尝试一个简单的do while循环,假设在输入小于1且大于1000时运行.它应该要求用户在循环中输入正确的数字.它现在似乎正在做的是再一次重复循环,要求输入正确,然后显示结束消息.如果满足条件,不确定为什么重复它
String name = JOptionPane.showInputDialog(null,
"Please enter students lastname");
int input = Integer.parseInt(JOptionPane.showInputDialog(null,
"Please enter students ID"));
do {
JOptionPane.showMessageDialog(null,
"Please enter a student ID within the correct parameters");
input = Integer.parseInt(JOptionPane.showInputDialog(null,
"Please enter students ID"));
} while (input < 1 && input > 1000);
// Output dialog with user input
JOptionPane.showMessageDialog(null, "StudentID: " + input
+ "\nStudent Last: " + name);
Run Code Online (Sandbox Code Playgroud)