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