forked from kokonior/Javascript-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonvert-suhu_adrnsyh.js
79 lines (78 loc) · 2.79 KB
/
konvert-suhu_adrnsyh.js
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
//program for convert suhu
var suhu = prompt('Input value to be converted(ex. 24,15) :');
var suhuasal = prompt('Converted from(ex. celcius,reamur)');
var suhutujuan = prompt('Converted to(ex. celcius,reamur) :');
var hasil=0;
//process celcius to fahrenheit,kelvin,reamur
if (suhuasal == "celcius") {
if (suhutujuan == "fahrenheit") {
hasil = suhu * 1.8 + 32;
} else {
if (suhutujuan == "kelvin") {
hasil = suhu + 273.15;
} else {
if (suhutujuan == "reamur") {
hasil = suhu * 0.8;
} else {
window.alert("Error");
}
}
}
//output
window.alert(hasil);
} else {
//process fahrenheit to celcius,kelvin,reamur
if (suhuasal == "fahrenheit") {
if (suhutujuan == "celcius") {
hasil = (suhu - 32) / 1.8;
} else {
if (suhutujuan == "kelvin") {
hasil = (suhu + 459.67) / 1.8;
} else {
if (suhutujuan == "reamur") {
hasil = (suhu - 32) / 2.25;
} else {
window.alert("Error");
}
}
}
} else {
//process kelvin to celcius,fahrenheit,reamur
if (suhuasal == "kelvin") {
if (suhutujuan == "celcius") {
hasil = suhu - 273.15;
} else {
if (suhutujuan == "fahrenheit") {
hasil = suhu * 1.8 - 459.67;
} else {
if (suhutujuan == "reamur") {
hasil = (suhu - 273.15) * 0.8;
} else {
window.alert("Error");
}
}
}
} else {
//process reamur to celcius,fahrenheit,reamur
if (suhuasal == "reamur") {
if (suhutujuan == "celcius") {
hasil = suhu * 1.25;
} else {
if (suhutujuan == "fahrenheit") {
hasil = suhu * 2.25 + 32;
} else {
if (suhutujuan == "kelvin") {
hasil = suhu * 1.25 + 273.15;
} else {
window.alert("Error");
}
}
}
} else {
window.alert("Error");
}
}
}
//output
window.alert(hasil);
}