码迷,mamicode.com
首页 > 编程语言 > 详细

两数求和java(字符串强转int型)

时间:2017-10-08 14:12:06      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:second   oid   ber   int   port   option   exit   enter   public   

 

import javax.swing.JOptionPane;

public class Addition {    public static void main( String args[] )    {      

                             String firstNumber,secondNumber;     

                            int number1, number2, sum;           

                            firstNumber =JOptionPane.showInputDialog( "Enter first integer" );

                            secondNumber = JOptionPane.showInputDialog( "Enter second integer" );

                            number1 = Integer.parseInt( firstNumber );      

                           number2 = Integer.parseInt( secondNumber );

                           sum = number1 + number2;

                          JOptionPane.showMessageDialog(          null, "The sum is " + sum, "Results",          JOptionPane.PLAIN_MESSAGE );

                          System.exit( 0 );    

}

}

两数求和java(字符串强转int型)

标签:second   oid   ber   int   port   option   exit   enter   public   

原文地址:http://www.cnblogs.com/mhj666/p/7637119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!