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
45 lines (37 loc) · 1.11 KB
/
TemperatureConvert.java
File metadata and controls
45 lines (37 loc) · 1.11 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
/* Nama : Chando Anggara Natanael Batubara
* Nim : 1301154390
* Kelas : IF 39-12
*/
import java.util.Scanner;
public class TemperaturConvert {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner celcius = new Scanner(System.in);
System.out.println("Masukkan Derajat Suhu : (celsius)");
int x = celcius.nextInt();
System.out.println("1. Reamur");
System.out.println("2. Fahrenheit");
System.out.println("3. Kelvin");
Scanner input = new Scanner(System.in);
System.out.println("Konvers kedalam : ");
int y = input.nextInt();
double hasil;
if ( y == 1)
{
hasil = x*4/5;
System.out.print("Hasil konvers = "+hasil+" Reamur");
}
else if ( y == 2)
{
hasil = (9/5* x) + 32;
System.out.print("Hasil konvers = "+hasil+" Fahrenheit");
}
else
{
hasil = x + 273;
System.out.print("Hasil konvers = "+hasil+" Kelvin");
}
}
}