zoukankan      html  css  js  c++  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);
    	}
    
    }
    
  • 相关阅读:
    spring中Bean的生命周期
    java之多线程
    struts2配置详解
    值栈
    数据校验和国际化
    2016年9月23日试题整理
    SpringMVC 文件上传下载
    CSS3 新增属性
    SpringMVC数据校验
    java中进程与线程--三种实现方式
  • 原文地址:https://www.cnblogs.com/gdp176119/p/4860051.html
Copyright © 2011-2022 走看看