forked from riya2001-cloud/java-hacktober
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuhu.java
59 lines (47 loc) · 1.56 KB
/
Suhu.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
package coba;
import java.util.ArrayList;
public class Suhu {
public static void main(String[] args) {
// nomor1
double senin = 29.3;
double selasa = 30.1;
double rabu = 32;
double kamis = 35.9;
double jumat = 36.7;
double sabtu = 33;
double minggu = 29;
double terkecil = 0;
// nomor2
ArrayList hari = new ArrayList();
hari.add("senin");
hari.add("selasa");
hari.add("rabu");
hari.add("kamis");
hari.add("jumat");
hari.add("sabtu");
hari.add("minggu");
double suhu[] = { 29.3, 30.1, 32, 35.9, 36.7, 33, 29 };
double suhumax = suhu[0];
double suhumin = suhu[0];
for (int i = 0; i < suhu.length; i++) {
if (suhu[i] > suhumax) {
suhumax = suhu[i];
}
for (int j = 0; j < suhu.length; j++) {
if (suhu[j] < suhumin) {
suhumin = suhu[j];
}
}
}
System.out.println(hari.get(0));
System.out.println(hari.get(1));
System.out.println(hari.get(2));
System.out.println(hari.get(3));
System.out.println(hari.get(4));
System.out.println(hari.get(5));
System.out.println(hari.get(6));
System.out.println("");
System.out.println("suhu tertinggi " + hari.get(4) + " " + suhumax);
System.out.println("suhu terendah " + hari.get(6) + " " + suhumin);
}
}