我正在尝试一个简单的 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);