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 (44 loc) · 1.4 KB
/
TemperatureConvert.java
File metadata and controls
45 lines (44 loc) · 1.4 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
package temperatureconvert;
import java.util.Scanner;
/**
*
* @author Kukuh Rahingga P
* 1301150035
* IF-39-07
*/
public class TemperatureConvert
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
System.out.print("Masukkan suhu dalam celcius : ");
float inp = input.nextInt();
int pil = 1;
while (pil < 4)
{
System.out.println("Masukkan angka untuk memilih");
System.out.println("1. Farenheit");
System.out.println("2. Reamur");
System.out.println("3. Kelfin");
System.out.println("4. Exit");
System.out.print("Pilih : ");
pil = input.nextInt();
float hasil;
switch(pil)
{
case 1 :
hasil = (inp * 9/5 + 32);
System.out.println(inp + " Celcius = " + hasil + " Farenheit \n");
break;
case 2 :
hasil = (inp * 4/5);
System.out.println(inp + " Celcius = " + hasil + " Reamur \n");
break;
case 3 :
hasil = (inp + 273);
System.out.println(inp + " Celcius = " + hasil + " Kelvin \n");
break;
}
}
}
}