|
@@ -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 centimeters*0.3937f;
|
|
11
|
+ }
|
|
12
|
+
|
|
13
|
+ public static float InchesToCentimeters(float inches){
|
|
14
|
+ if(inches <= 0){
|
|
15
|
+ return 0;
|
|
16
|
+ }else
|
|
17
|
+ return inches*2.54f;
|
|
18
|
+ }
|
|
19
|
+
|
|
20
|
+ public static float FeetToMeters(float feet){
|
|
21
|
+ if(feet <= 0){
|
|
22
|
+ return 0;
|
|
23
|
+ }else
|
|
24
|
+ return feet*0.3048f;
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ public static float MetersToFeet(float meters){
|
|
28
|
+ if(meters <= 0){
|
|
29
|
+ return 0;
|
|
30
|
+ }else
|
|
31
|
+ return meters*3.2808f;
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
35
|
+ return celsius*9/5 + 32;
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
39
|
+ return (fahrenheit- 32)*5/9;
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ public static float MphToKph(float mph){
|
|
43
|
+ if(mph <= 0){
|
|
44
|
+ return 0;
|
|
45
|
+ }else
|
|
46
|
+ return mph*1.609f;
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ public static float KphToMph(float kph){
|
|
50
|
+ if(kph <= 0){
|
|
51
|
+ return 0;
|
|
52
|
+ }else
|
|
53
|
+ return kph*0.62137f;
|
|
54
|
+ }
|
21
|
55
|
}
|