-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtutorial_10.java
46 lines (37 loc) · 967 Bytes
/
tutorial_10.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Driver {
public static void main(String[] args) {
int num1 = 5, num2 = 4, num3 = 9;
// change value of num1
num1 = num2;
num1 = 23;
// add 6 to num1
num1 = num1 + 6;
num1 += 6;
// subtract 2 from num1
num1 = num1 - 2;
num1 -= 2;
// divide num1 by 3
num1 = num1 / 3;
num1 /= 3;
// multiply num1 by 10;
num1 = num1 * 10;
num1 *= 10;
// all arithmetic operations follow PEMDAS
num1 = 3;
num1 = 4 * num2 + num3 - 1 + 10 / 2 % num1;
// 4 * 4 + 9 - 1 + 10 / 2 % 3
// 16 + 9 - 1 + 10 / 2 % 3
// 16 + 9 - 1 + 5 % 3
// 16 + 9 - 1 + 2
// 25 - 1 + 2
// 24 + 2
// 26
// num1 = 26
num1 = (2 + 5) * num1 - num2;
// 2 + 5 * 26 - 4
// 7 * 26 - 4
// 182 - 4
// 178
// num1 = 178
}
}