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

java运算

时间:2015-10-08 10:24:47      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

(一)

截图:

技术分享技术分享技术分享

技术分享技术分享技术分享

程序:

import javax.swing.JOptionPane;
public class Addition {
	public static void main (String args[]){
		String firstNumber,secondNumber;
		int number1,number2,sum,cha,ji,chu;
		//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");
		number1=Integer.parseInt(firstNumber);	
		number2=Integer.parseInt(secondNumber);
		//convert numbers from type String to int
		sum=number1+number2;
		
		cha=number1-number2;
		ji=number1*number2;
		chu=number1/number2;
		JOptionPane.showMessageDialog(null, "the sum is"+sum,"Reesults",
				JOptionPane.PLAIN_MESSAGE);
		JOptionPane.showMessageDialog(null, "the cha is"+cha,"Reesults",
				JOptionPane.PLAIN_MESSAGE);
		JOptionPane.showMessageDialog(null, "the ji is"+ji,"Reesults",
				JOptionPane.PLAIN_MESSAGE);
		JOptionPane.showMessageDialog(null, "the chu is"+chu,"Reesults",
				JOptionPane.PLAIN_MESSAGE);
		System.exit(0);
	}

}

 

java运算

标签:

原文地址:http://www.cnblogs.com/gdp176119/p/4860051.html

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