首页 > 编程语言 > 详细

java对话框形式实现加减乘除

时间:2015-10-08 00:22:48      阅读:162      评论:0      收藏:0      [点我收藏+]
import javax.swing.JOptionPane;  // import class JOptionPane

public class sumit{
   public static void main( String args[] )
   {
      String firstNumber,   // first string entered by user
             secondNumber;  // second string entered by user
      int number1,          // first number to add
          number2;         // second number to add
        
      // read in first number from user as a string
      firstNumber =
         JOptionPane.showInputDialog( "Enter first integer" );

      // read in second number from user as a string
      secondNumber =
         JOptionPane.showInputDialog( "Enter second integer" );

      // convert numbers from type String to type int
      number1 = Integer.parseInt( firstNumber ); 
      number2 = Integer.parseInt( secondNumber );

      

      // display the results
      JOptionPane.showMessageDialog(
         null, "The sum is: / 和数是:  " +(number1+number2)
         +"\n"+"The difference is: / 减数是:"+(number1-number2)
         +"\n"+"The product is: / 积是:"+(number1*number2)
         +"\n"+"The division is: / 商是:"+(number1/number2)
       );
      

      System.exit( 0 );   // terminate the program
   }
}

技术分享

技术分享

技术分享

 

java对话框形式实现加减乘除

原文:http://www.cnblogs.com/kk-95/p/4859856.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!