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