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
57 lines (53 loc) · 1.6 KB
/
TemperatureConvert.java
File metadata and controls
57 lines (53 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
51
52
53
54
55
56
57
/*
* Alfian Rahman Aziz
* 1301150063
* IF 39-07
*/
import java.util.Scanner;
public class TemperatureConvert {
public static void main(String[] args) {
int n;
float c;
Scanner scan = new Scanner(System.in);
System.out.println("Input number of Celcius :");
c = scan.nextInt();
System.out.println("Choose to Convert");
System.out.println ("1. Convert To Reamur");
System.out.println("2. Convert to Fahrenheit");
System.out.println("3. Convert To Kelvin");
System.out.println("choose 1 to 3");
n = scan.nextInt();
switch (n) {
case 1:
ToReamur(c);
break;
case 2:
ToFahrenheit(c);
break;
case 3:
ToKelvin(c);
break;
}
}
public static void ToReamur(float c) {
float r;
Scanner scan = new Scanner(System.in);
r = (float) (c * 0.8);
System.out.println(c + " degrees Celcius is");
System.out.println(r + " degrees Reamur");
}
public static void ToFahrenheit(float c) {
float f;
Scanner scan = new Scanner(System.in);
f = (float) (c * 1.8 + 32);
System.out.println(c + " degrees Celcius is");
System.out.println(f + " degrees Fahrenheit");
}
public static void ToKelvin(float c) {
float k;
Scanner scan = new Scanner(System.in);
k = (float) (c + 273.15);
System.out.println(c + " degrees Celcius is");
System.out.println(k + " degrees Kelvin");
}
}