所以我很困惑这个问题,现在让我感到困惑。这是个问题:
"要求用户输入起始编号和结束编号。在表格中打印出所有数字及其平方值。"
import javax.swing.JOptionPane;
public class P4_1
{
public static void main(String[] args)
{
String response_1 = JOptionPane.showInputDialog(null, "Please enter the starting number: ");
int start_number = Integer.parseInt(response_1);
String response_2 = JOptionPane.showInputDialog(null, "Please enter the ending number: ");
int end_number = Integer.parseInt(response_2);
int set = start_number;
while(start_number > end_number);
{
set++;
}
JOptionPane.showMessageDialog(null, set);
JOptionPane.showConfirmDialog(null, "Would you like to run the program again? ");
}
}
答案 0 :(得分:1)
“要求用户输入起始编号和结束编号。在表格中打印所有编号及其平方值。”
问题是你希望每次通过JOptionPane提示输入整数时提示用户两次。
因此,如果用户输入3和5,则打印出3到5的正方形:
i.e: 9 16 25