forked from ddthien-coder/trainingjava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toantu.java
80 lines (69 loc) · 2.42 KB
/
toantu.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
public class toantu {
// toan tu + - * / %
// toan tu ++ -- += -=
// toan tu ==, !=
// toan tu ><, >=
public static void main(String[] args) {
int result = 3+2;
System.out.println(result);
int newResult = result*10;
System.out.println(result + "*10= " + newResult);
int previousResult=newResult;
newResult = newResult/15;
System.out.println(previousResult + "/15= " + newResult );
newResult=previousResult%15;
System.out.println(previousResult + "%15= " + newResult);
newResult++; // newResult = newResult+1;
System.out.println("the result is = "+ newResult);
newResult--;
System.out.println("the result is = "+ newResult);
newResult+=2;
// newResult = newResult+2;
System.out.println("the result is = "+ newResult);
newResult-=2;
// newResult = newResult-2;
System.out.println("the result is = "+ newResult);
if(newResult==2) {
System.out.println("The Result is 2");
}
if(newResult!=2) {
System.out.println("the Result is not 2");
}
if(newResult>1) {
System.out.println("the Result is higher than 1");
}
if(newResult>=2) {
System.out.println("the Result is higher or equal than 1");
}
// toan tu && ||
// toan tu boolean
// toan tu dieu kien
int firstNumber = 10;
if ((firstNumber<5) && (firstNumber<15)) {
// ca 2 dieu kien phai dung
System.out.println("The number in the range 5 to 15");
}
if ((firstNumber>5) || (firstNumber<10)) {
// 1 trong 2 dieu kien dung
System.out.println("The number is higher 5 or lower than 10");
}
boolean isBoss= false;
if(isBoss ==true) {
System.out.println("this is boss");
}else{
System.out.println("this isn't boss");
}
if(isBoss=true){
System.out.println("why run");
// >> day chi la phep gan nen bieu thuc nay van chay
}
// toan tu dieu kien
int score = 9;
boolean ishighScore= score>8?true:false;
if (ishighScore) {
System.out.println(" You are get the high score");
} else {
System.out.println(" You are get lower score");
}
}
}