-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
39 lines (27 loc) · 1 KB
/
Main.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
public class Main {
public static void main(String[] args) {
// Operasi Aritmatika
int variable1 = 10;
int variable2 = 5;
int hasil;
// 1. penjumlahan
hasil = variable1 + variable2;
System.out.println(variable1 + " + " + variable2 + " = " + hasil);
// 2. pengurangan
hasil = variable1 - variable2;
System.out.printf("%d - %d = %d \n",variable1,variable2,hasil);
// 3. perkalian
hasil = variable1 * variable2;
System.out.printf("%d x %d = %d \n",variable1,variable2,hasil);
// 4. pembagian
hasil = variable1 / variable2;
System.out.printf("%d / %d = %d \n",variable1,variable2,hasil);
float a = 6;
float b = 5;
float hasilFloat = a/b;
System.out.println(a + " / " + b + " = " + hasilFloat);
// 5. modulus (sisa pembagian)
hasil = variable1 % variable2;
System.out.printf("%d %% %d = %d \n",variable1,variable2,hasil);
}
}