|
@@ -1,21 +1,69 @@
|
1
|
1
|
public class ConversionTool {
|
|
2
|
+ enum metrics{}
|
2
|
3
|
|
|
4
|
+
|
3
|
5
|
|
4
|
6
|
public static void main(String[] args){}
|
5
|
7
|
|
6
|
|
- public static float CentimetersToInches(float centimeters){}
|
|
8
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
9
|
+ return (celsius * 9) / 5 + 32;
|
|
10
|
+ }
|
7
|
11
|
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
|
12
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
13
|
+ return (fahrenheit - 32) * 5 / 9;
|
|
14
|
+ }
|
9
|
15
|
|
10
|
|
- public static float FeetToMeters(float feet){}
|
|
16
|
+ public static float CentimetersToInches(float centimeters){
|
|
17
|
+ float CM2IN = 0.3937007874f;
|
|
18
|
+ if(centimeters <= 0f){
|
|
19
|
+ return 0;
|
|
20
|
+ }
|
|
21
|
+ else
|
|
22
|
+ return centimeters * CM2IN;
|
|
23
|
+ }
|
11
|
24
|
|
12
|
|
- public static float MetersToFeet(float meters){}
|
|
25
|
+ public static float InchesToCentimeters(float inches){
|
|
26
|
+ float IN2CM = 2.54f;
|
|
27
|
+ if(inches <= 0){
|
|
28
|
+ return 0;
|
|
29
|
+ }
|
|
30
|
+ else
|
|
31
|
+ return inches * IN2CM;
|
|
32
|
+ }
|
13
|
33
|
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
|
34
|
+ public static float FeetToMeters(float feet){
|
|
35
|
+ float FT2MT = 0.3048f;
|
|
36
|
+ if(feet <= 0){
|
|
37
|
+ return 0;
|
|
38
|
+ }
|
|
39
|
+ else
|
|
40
|
+ return feet * FT2MT;
|
|
41
|
+ }
|
15
|
42
|
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
|
43
|
+ public static float MetersToFeet(float meters){
|
|
44
|
+ float MT2FT = (float) 3.280839895f;
|
|
45
|
+ if(meters <= 0){
|
|
46
|
+ return 0;
|
|
47
|
+ }
|
|
48
|
+ else
|
|
49
|
+ return meters * MT2FT;
|
|
50
|
+ }
|
17
|
51
|
|
18
|
|
- public static float MphToKph(float mph){}
|
|
52
|
+ public static float MphToKph(float mph){
|
|
53
|
+ float MPH2KPH = 1.609344f;
|
|
54
|
+ if(mph <= 0){
|
|
55
|
+ return 0;
|
|
56
|
+ }
|
|
57
|
+ else
|
|
58
|
+ return mph * MPH2KPH;
|
|
59
|
+ }
|
19
|
60
|
|
20
|
|
- public static float KphToMph(float kph){}
|
|
61
|
+ public static float KphToMph(float kph){
|
|
62
|
+ float KPH2MPH = 0.6213711922f;
|
|
63
|
+ if(kph <= 0){
|
|
64
|
+ return 0;
|
|
65
|
+ }
|
|
66
|
+ else
|
|
67
|
+ return kph * KPH2MPH;
|
|
68
|
+ }
|
21
|
69
|
}
|