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