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