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