|
@@ -1,21 +1,39 @@
|
1
|
1
|
public class ConversionTool {
|
2
|
2
|
|
3
|
3
|
|
4
|
|
- public static void main(String[] args){}
|
|
4
|
+ public static void main(String[] args){
|
|
5
|
+
|
|
6
|
+ }
|
5
|
7
|
|
6
|
|
- public static float CentimetersToInches(float centimeters){}
|
|
8
|
+ public static float CentimetersToInches(float centimeters){
|
|
9
|
+ return centimeters < 0 ? 0 : centimeters * 0.393701f;
|
|
10
|
+ }
|
7
|
11
|
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
|
12
|
+ public static float InchesToCentimeters(float inches){
|
|
13
|
+ return inches < 0 ? 0 : inches * 2.54f;
|
|
14
|
+ }
|
9
|
15
|
|
10
|
|
- public static float FeetToMeters(float feet){}
|
|
16
|
+ public static float FeetToMeters(float feet){
|
|
17
|
+ return feet < 0 ? 0 : feet * 0.3048f;
|
|
18
|
+ }
|
11
|
19
|
|
12
|
|
- public static float MetersToFeet(float meters){}
|
|
20
|
+ public static float MetersToFeet(float meters){
|
|
21
|
+ return meters < 0 ? 0 : meters * 3.28084f;
|
|
22
|
+ }
|
13
|
23
|
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
|
24
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
25
|
+ return (celsius * 1.8f) + 32;
|
|
26
|
+ }
|
15
|
27
|
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
|
28
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
29
|
+ return (fahrenheit - 32) / 1.8f;
|
|
30
|
+ }
|
17
|
31
|
|
18
|
|
- public static float MphToKph(float mph){}
|
|
32
|
+ public static float MphToKph(float mph){
|
|
33
|
+ return mph < 0 ? 0 : mph * 1.60934f;
|
|
34
|
+ }
|
19
|
35
|
|
20
|
|
- public static float KphToMph(float kph){}
|
|
36
|
+ public static float KphToMph(float kph){
|
|
37
|
+ return kph < 0 ? 0 : kph * 0.62137f;
|
|
38
|
+ }
|
21
|
39
|
}
|