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