mathoperdemo.java

来自「JAVA的一些基础教程」· Java 代码 · 共 48 行

JAVA
48
字号
public class MathOperDemo {
	public static void main(String[] args) {

 	int i = 64;
 	int j = 58;
 	double x = 3.1415926;
 	double y = 9.11;


	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("\n执行加法操作");
	System.out.println("    i + j = " + (i + j));
	System.out.println("    x + y = " + (x + y));

	//减法运算
	System.out.println("\n执行减法运算");
	System.out.println("    i - j = " + (i - j));
	System.out.println("    x - y = " + (x - y));

	//乘法运算
	System.out.println("\n执行乘法运算");
	System.out.println("    i * j = " + (i * j));
	System.out.println("    x * y = " + (x * y));

	//除法运算
	System.out.println("\n执行除法运算");
	System.out.println("    i / j = " + (i / j));
	System.out.println("    x / y = " + (x / y));

	//求余运算
	System.out.println("\n执行求余运算");
	System.out.println("    i % j = " + (i % j));
	System.out.println("    x % y = " + (x % y));

	//混合数据类型运算
	System.out.println("\n执行混合数据类型运算");
	System.out.println("    j + y = " + (j + y));
	System.out.println("    i * x = " + (i * x));
	}
}

⌨️ 快捷键说明

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