java运算

(一)

截图:

java运算java运算java运算

java运算java运算java运算

程序:

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);
} }
上一篇:Josephus问题的java实现


下一篇:关于linux下部署JavaWeb项目,nginx负责静态资源访问,tomcat负责处理动态请求的nginx配置