|
@@ -3,19 +3,93 @@ public class ConversionTool {
|
3
|
3
|
|
4
|
4
|
public static void main(String[] args){}
|
5
|
5
|
|
6
|
|
- public static float CentimetersToInches(float centimeters){}
|
|
6
|
+ public static float CentimetersToInches(float centimeters){
|
|
7
|
+ double d = 0.393701;
|
|
8
|
+ float f = (float)d;
|
|
9
|
+
|
|
10
|
+ if(centimeters > 0){
|
|
11
|
+ centimeters = centimeters * f;
|
|
12
|
+ }else{
|
|
13
|
+ centimeters = 0;
|
|
14
|
+ }
|
|
15
|
+ return centimeters;
|
|
16
|
+ }
|
7
|
17
|
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
|
18
|
+ public static float InchesToCentimeters(float inches){
|
|
19
|
+ double d = 2.54;
|
|
20
|
+ float f = (float)d;
|
|
21
|
+
|
|
22
|
+ if(inches > 0){
|
|
23
|
+ inches = inches * f;
|
|
24
|
+ }else{
|
|
25
|
+ inches = 0;
|
|
26
|
+ }
|
|
27
|
+ return inches;
|
|
28
|
+ }
|
9
|
29
|
|
10
|
|
- public static float FeetToMeters(float feet){}
|
|
30
|
+ public static float FeetToMeters(float feet){
|
|
31
|
+ double d = 0.3048;
|
|
32
|
+ float f = (float)d;
|
|
33
|
+
|
|
34
|
+ if(feet > 0){
|
|
35
|
+ feet = feet * f;
|
|
36
|
+ }else{
|
|
37
|
+ feet = 0;
|
|
38
|
+ }
|
|
39
|
+ return feet;
|
|
40
|
+ }
|
11
|
41
|
|
12
|
|
- public static float MetersToFeet(float meters){}
|
|
42
|
+ public static float MetersToFeet(float meters){
|
|
43
|
+ double d = 3.28084;
|
|
44
|
+ float f = (float)d;
|
|
45
|
+
|
|
46
|
+ if(meters > 0){
|
|
47
|
+ meters = meters * f;
|
|
48
|
+ }else{
|
|
49
|
+ meters = 0;
|
|
50
|
+ }
|
|
51
|
+ return meters;
|
|
52
|
+ }
|
13
|
53
|
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
|
54
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
55
|
+ double d = (celsius * (1.8)) + 32;
|
|
56
|
+ float f = (float)d;
|
|
57
|
+
|
|
58
|
+ celsius = f;
|
|
59
|
+
|
|
60
|
+ return celsius;
|
|
61
|
+ }
|
15
|
62
|
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
|
63
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
64
|
+ double d = ((fahrenheit - 32) * 5)/9;
|
|
65
|
+ float f = (float)d;
|
|
66
|
+
|
|
67
|
+ fahrenheit = f;
|
|
68
|
+
|
|
69
|
+ return fahrenheit;
|
|
70
|
+ }
|
17
|
71
|
|
18
|
|
- public static float MphToKph(float mph){}
|
|
72
|
+ public static float MphToKph(float mph){
|
|
73
|
+ double d = 1.60934;
|
|
74
|
+ float f = (float)d;
|
|
75
|
+
|
|
76
|
+ if(mph > 0){
|
|
77
|
+ mph = mph * f;
|
|
78
|
+ }else{
|
|
79
|
+ mph = 0;
|
|
80
|
+ }
|
|
81
|
+ return mph;
|
|
82
|
+ }
|
19
|
83
|
|
20
|
|
- public static float KphToMph(float kph){}
|
|
84
|
+ public static float KphToMph(float kph){
|
|
85
|
+ double d = 0.621371;
|
|
86
|
+ float f = (float)d;
|
|
87
|
+
|
|
88
|
+ if(kph > 0){
|
|
89
|
+ kph = kph * f;
|
|
90
|
+ }else{
|
|
91
|
+ kph = 0;
|
|
92
|
+ }
|
|
93
|
+ return kph;
|
|
94
|
+ }
|
21
|
95
|
}
|