代码
提交代码
public class OperateDemo5 { public static void main(String[] args) { // 分组初始化三个变量 num1、num2、result,值分别为 20、10、0 int num1 = 20, num2 = 10, result = 0; System.out.println("初始值:"); System.out.print("num1=" + num1 + '\t'); System.out.print("num2=" + num2 + '\t'); System.out.print("result=" + result + "\t\n"); System.out.println("开始赋值运算:"); result += num1; System.out.println("result += num1 结果为:" + result); result -= num2; System.out.println("result -= num2 结果为:" + result); result *= num1; System.out.println("result *= num1 结果为:" + result); result /= num2; System.out.println("result /= num2 结果为:" + result); result %= 15; System.out.println("result %= 15 结果为:" + result); } }
运行结果