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
50 lines (46 loc) · 1.6 KB
/
TemperatureConvert.java
File metadata and controls
50 lines (46 loc) · 1.6 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
/**
* Nafasa Muth Ma'nah
* 1301150441
*/
package TemperatureConvert;
import java.util.Scanner;
public class TemperatureConvert{
public static void main(String[] args) {
Scanner konversi = new Scanner(System.in);
double celcius, reamur, fahrenheit, kelvin;
int counter = 0, pilih, lagi;
System.out.print("Masukkan Suhu : "); //Suhu dengan derajat celcius
celcius = konversi.nextDouble();
while (counter == 0){
System.out.println("1. Reamur");
System.out.println("2. Fahrenheit");
System.out.println("3. Kelvin");
System.out.println("Pilihan : ");
pilih = konversi.nextInt();
switch(pilih){
case 1:
reamur = 0.8 * celcius;
System.out.println(reamur + " derajat reamur");
break;
case 2:
fahrenheit = (1.8 * celcius) + 32;
System.out.println(fahrenheit + " derajat fahrenheit");
break;
case 3:
kelvin = celcius + 273;
System.out.println(kelvin + " derajat kelvin");
break;
}
System.out.println("Apakah Anda Ingin Mengkonversi Suhu Lagi ? ");
System.out.println("1. Ya");
System.out.println("2. Tidak");
lagi = konversi.nextInt();
if(lagi == 1){
System.out.println(pilih);
}
else{
System.exit(0);
}
}
}
}