小编Shi*_*fty的帖子

JOptionPane和读取整数 - 初学者Java

我目前有代码,用于读取用户在一行中输入的月份,日期和年份(以空格分隔).这是代码.

Scanner input = new Scanner(System.in);
int day = 0;
int month = 0;
int year = 0;

System.out.printf("enter the month, date, and year(a 2 numbered year). Put a space between the month, day, and year");
month = input.nextInt();
day = input.nextInt();
year = input.nextInt();
Run Code Online (Sandbox Code Playgroud)

这个工作正常,第二部分是显示一条消息,如果是月*天==年,那么它是一个神奇的数字,如果没有,那么它不是一个神奇的数字.它必须显示在对话框中.这是我的代码,它工作得很好.

  if((day * month) == year)
  {
    String message = String.format("%s", "The date you entered is MAGIC!");//If the day * month equals the year, then it is a magic number
    JOptionPane.showMessageDialog(null, message);
  }
  if((day * …
Run Code Online (Sandbox Code Playgroud)

java swing joptionpane

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

joptionpane ×1

swing ×1