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
48 lines (32 loc) · 1.19 KB
/
TemperatureConvert.java
File metadata and controls
48 lines (32 loc) · 1.19 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package TemperatureConvert;
import java.util.Scanner;
/**
*
* @author A455ld
*/
public class TemperatureConvert {
public static void main(String[] args) {
Scanner derajat = new Scanner (System.in);
double ceksuhu ;
System.out.println("tentukan suhu saat ini (celcius):");
ceksuhu = derajat.nextDouble();
System.out.println("pilihan konversi");
System.out.println("[1]fahrenheit\n[2]kelvin\n[3]rheamur");
int pk = derajat.nextInt();
if (pk==1){
ceksuhu = ceksuhu * 9/5 + 32;
System.out.println("hasil : "+ceksuhu);
}else if (pk==2){
ceksuhu = ceksuhu + 273.15;
System.out.println("hasil : "+ceksuhu);
}else if (pk==3){
ceksuhu = ceksuhu * 0.8;
System.out.println("hasil : "+ceksuhu);
}
}
}