zoukankan      html  css  js  c++  java
  • 编写一个程序,用户输入两个数,求出其加减乘除,并用消息框显示计算结果

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

                    

       

    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)

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

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

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

            } 

    }

    结果截屏:

  • 相关阅读:
    (转)Ubuntu init启动流程分析
    读懂diff
    vs2010 sp1
    Git .gitignore文件的使用
    第一次尝试节奏跑(乳酸门槛跑)
    放松跑、间歇跑、节奏跑和LSD
    Tomcat6配置webdav协议
    Content-disposition
    php5.3到php7.0.x新特性介绍
    随机生成字符串
  • 原文地址:https://www.cnblogs.com/sunmei20142925/p/4856042.html
Copyright © 2011-2022 走看看