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
72 lines (65 loc) · 2.52 KB
/
TemperatureConvert.java
File metadata and controls
72 lines (65 loc) · 2.52 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
//Sylvia Dwi Anggraini
//1301154469
//if-39-07
package TemperatureConvert;
import java.util.Scanner;
public class TemperatureConvert{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double c, r, f, k, kelvin, reamur, fahrenheit, celcius;
int x=0;
while(x==0){
System.out.println("Temperature Convert");
System.out.println("1. Celcius");
System.out.println("2. Reamur");
System.out.println("3. Fahrenheit");
System.out.println("4. Kelvin");
System.out.print(" Pilih : ");
int pil = input.nextInt();
switch(pil){
case 1 :
System.out.print("Masukkan Suhu Celcius : ");
c = input.nextDouble();
reamur = 0.8*c;
fahrenheit = (1.8*c)+32;
kelvin = c+273;
System.out.println(reamur+"' reamur dan "+ fahrenheit+"' fahrenheit dan "+ kelvin+"' kelvin");
break;
case 2 :
System.out.println("Masukkan Suhu Reamur : ");
r = input.nextDouble();
celcius = 1.25*r;
fahrenheit = (2.25*r)+32;
kelvin = (1.25*r)+273;
System.out.println(celcius+"' celcius dan "+ fahrenheit+"' fahrenheit"+ kelvin+"' kelvin");
break;
case 3 :
System.out.println("Masukkan Suhu Fahrenheit : ");
f = input.nextDouble();
celcius = 0.556*(f-32);
reamur = 0.444*(f-32);
kelvin = 0.556*(f-32)+273;
System.out.println(celcius+"' celcius dan "+ reamur+"' reamur"+ kelvin+"' kelvin");
break;
case 4 :
System.out.println("Masukkan Suhu Kelvin : ");
k = input.nextDouble();
celcius = k-273;
reamur = 0.8*(k-273);
fahrenheit = 1.8*(k-273)+32;
System.out.println(celcius+"' celcius dan "+ reamur+"' reamur dan "+fahrenheit+"' fahrenheit.");
break;
}
System.out.println("Apakah Ingin mencoba lagi? ");
System.out.println("1. Ya");
System.out.println("2. Tidak");
System.out.print("Pilih : ");
pil = input.nextInt();
if (pil==1){
System.out.println(pil);
}
else{
System.exit(0);
}
}}
}