forked from OOP-ADF/Task_1
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperatureConvert.java
More file actions
Latest commit
76 lines (57 loc) · 2.51 KB
/
Copy pathTemperatureConvert.java
File metadata and controls
76 lines (57 loc) · 2.51 KB
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
/* Nindia Cahyaning Putri IF 3907 1301154567 */
packagetemperatureconvert;
importjava.util.Scanner;
publicclassTemperatureConvert {
publicstaticvoidmain(String[] args) {
Scannermasukan = newScanner (System.in);
doublec, r = 0, f, k, celcius, reamur, fahrenheit, kelvin;
System.out.println("Temperature Convert");
System.out.println("1. Reamur");
System.out.println("2. Celcius");
System.out.println("3. Fahrenheit");
System.out.print("Pilih = ");
intx = masukan.nextInt();
switch (x) {
case1:
System.out.print("Masukkan Suhu dalam Reamur = ");
r = masukan.nextDouble();
celcius = (1.25*r);
fahrenheit = (2.25*r+32);
kelvin = (celcius + 273);
System.out.println("Reamur = " +celcius);
System.out.println("Fahrenheit = " +fahrenheit);
System.out.println("Kelvin = "+kelvin);
break;
case2:
System.out.print("Masukkan Suhu dalam Celcius = ");
c = masukan.nextDouble();
reamur = (0.8*c);
fahrenheit = (1.8*c+32);
kelvin = ((1.25*r)+273);
System.out.println("Reamur = " +reamur);
System.out.println("Fahrenheit = " +fahrenheit);
System.out.println("Klevin = " +kelvin);
break;
case3:
System.out.print("Masukkan Suhu dalam Fahrenheit = ");
f = masukan.nextDouble();
celcius = (0.555*(f-32));
reamur = (0.444*(f-32));
kelvin = (0.556*(f-32)+273);
System.out.println("Reamur = " +reamur);
System.out.println("Celcius = " +celcius);
System.out.println("Kelvin = " +kelvin);
break;
case4:
System.out.println("Masukkan Suhu dalam Kelvin ");
k = masukan.nextDouble();
celcius = (k-273);
reamur = (0.8*(k-273));
fahrenheit = 2.25*(k-273)+32;
System.out.println("Celcius = " +celcius);
System.out.println("Reamur = "+reamur);
System.out.println("Fahrenheit = "+fahrenheit);
break;
}
}
}