|
@@ -1,21 +1,57 @@
|
1
|
1
|
public class ConversionTool {
|
2
|
2
|
|
3
|
3
|
|
4
|
|
- public static void main(String[] args){}
|
5
|
|
-
|
6
|
|
- public static float CentimetersToInches(float centimeters){}
|
7
|
|
-
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
9
|
|
-
|
10
|
|
- public static float FeetToMeters(float feet){}
|
11
|
|
-
|
12
|
|
- public static float MetersToFeet(float meters){}
|
13
|
|
-
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
15
|
|
-
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
17
|
|
-
|
18
|
|
- public static float MphToKph(float mph){}
|
19
|
|
-
|
20
|
|
- public static float KphToMph(float kph){}
|
|
4
|
+ public static void main(String[] args){
|
|
5
|
+
|
|
6
|
+ }
|
|
7
|
+
|
|
8
|
+ public static float CentimetersToInches(float centimeters){
|
|
9
|
+ if(centimeters > 0){
|
|
10
|
+ return centimeters * (float) 0.393701;
|
|
11
|
+ }
|
|
12
|
+ return 0;
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+ public static float InchesToCentimeters(float inches){
|
|
16
|
+ if(inches > 0){
|
|
17
|
+ return inches / (float) 0.393701;
|
|
18
|
+ }
|
|
19
|
+ return 0;
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ public static float FeetToMeters(float feet){
|
|
23
|
+ if (feet > 0){
|
|
24
|
+ return feet * (float) 0.3048;
|
|
25
|
+ }
|
|
26
|
+ return 0;
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ public static float MetersToFeet(float meters){
|
|
30
|
+ if (meters > 0){
|
|
31
|
+ return meters / (float) 0.3048;
|
|
32
|
+ }
|
|
33
|
+ return 0;
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
37
|
+ return (celsius * (float)1.8) + 32;
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
41
|
+ return (fahrenheit - 32) / (float)1.8;
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ public static float MphToKph(float mph){
|
|
45
|
+ if (mph > 0){
|
|
46
|
+ return mph * (float) 1.60934;
|
|
47
|
+ }
|
|
48
|
+ return 0;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ public static float KphToMph(float kph){
|
|
52
|
+ if (kph > 0){
|
|
53
|
+ return kph / (float) 1.60934;
|
|
54
|
+ }
|
|
55
|
+ return 0;
|
|
56
|
+ }
|
21
|
57
|
}
|