编写一个程序,用户输入两个数,求出其加减乘除,并用消息框显示计算结果

                

   

import javax.swing.JOptionPane;

public class Test{

public static void main(String[] args) {

    int n1=Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));

    int n2=Integer.parseInt(JOptionPane.showInputDialog("Input number 2: ")) ;   //获取从JOptionPane.showInputDialog对话框中输入的值,然后转换为int类型

    JOptionPane.showMessageDialog(null,"The sum is:"+(n1+n2)

          +"\n"+"The difference is:"+(n1-n2)                                                                                   

          +"\n"+"The product is:"+(n1*n2)

          +"\n"+"The division is:"+(n1/n2));

        } 

 

}

结果截屏:

编写一个程序,用户输入两个数,求出其加减乘除,并用消息框显示计算结果

编写一个程序,用户输入两个数,求出其加减乘除,并用消息框显示计算结果

 

编写一个程序,用户输入两个数,求出其加减乘除,并用消息框显示计算结果

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案