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