arithmeticexample.java

来自「java语言与面向对象程序设计源程序」· Java 代码 · 共 40 行

JAVA
40 行
字号
public class ArithmeticExample 
    {  public static void main(String[] args) 
      { //定义几个变量并赋值
        int i = 37;
        int j = 42;
        double x = 27.475;
        double y = 7.22;
        System.out.println("变量数值:");
        System.out.println(" i = " + i);
        System.out.println(" j = " + j);
        System.out.println(" x = " + x);
        System.out.println(" y = " + y);
       //加法
        System.out.println("加:");
        System.out.println(" i + j = " + (i + j));
        System.out.println(" x + y = " + (x + y));
       //减法
        System.out.println("减:");
        System.out.println(" i - j = " + (i - j));
        System.out.println(" x - y = " + (x - y));
       //乘法
        System.out.println("乘:");
        System.out.println(" i * j = " + (i * j));
        System.out.println(" x * y = " + (x * y));
       //除法
        System.out.println("除:");
        System.out.println(" i / j = " + (i / j));
        System.out.println(" x / y = " + (x / y));
       //从除法中求得余数
        System.out.println("计算余数:");
        System.out.println(" i % j = " + (i % j));
        System.out.println(" x % y = " + (x % y));
       //混合类型
        System.out.println("混合类型:");
        System.out.println(" j + y = " + (j + y));
        System.out.println(" i * x = " + (i * x));
        }
      }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?