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