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
34 lines (32 loc) · 958 Bytes
/
TemperatureConvert.java
File metadata and controls
34 lines (32 loc) · 958 Bytes
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
import java.util.Scanner;
public class ConvertSuhu {
public static void main(String[] args) {
double suhu, Fahrenheit, Reamur, Kelvin;
int b;
Scanner cin = new Scanner(System.in);
System.out.println("KONVERSI SUHU");
System.out.print("Masukkan suhu dalam satuan Celcius: ");
suhu=cin.nextDouble();
System.out.println("Suhu akan diubah ke: ");
System.out.println("1. Fahreheit");
System.out.println("2. Reamur");
System.out.println("3. Kelvin");
System.out.print("Masukkan Pilihan: ");
b=cin.nextInt();
Fahrenheit=(1.8*suhu)+32;
Reamur=0.8*suhu;
Kelvin=suhu+273;
if (b==1) {
System.out.println("Convert suhu Celcius ke Fahrenheit: "+Fahrenheit);
}
else if (b==2) {
System.out.println("Convert suhu Celcius ke Reamur: "+Reamur);
}
else if (b==3) {
System.out.println("Convert suhu ke Kelvin: "+Kelvin);
}
else {
System.out.println("Tidak ada pilihan");
}
}
}