|
@@ -1,21 +1,96 @@
|
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){}
|
|
5
|
+ public static float CentimetersToInches(float centimeters){
|
|
6
|
+ float value =0;
|
|
7
|
+ if (centimeters > 0){
|
|
8
|
+ float n = centimeters * 0.393701f;
|
|
9
|
+ value = n;
|
|
10
|
+ return value;
|
|
11
|
+ }
|
|
12
|
+ else{
|
|
13
|
+ }
|
|
14
|
+ return 0;
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ public static float InchesToCentimeters(float inches){
|
|
18
|
+ float value = 0;
|
|
19
|
+ if (inches > 0){
|
|
20
|
+ float n = inches * 2.54f;
|
|
21
|
+ value = n;
|
|
22
|
+ return value;}
|
|
23
|
+ else{
|
|
24
|
+ }
|
|
25
|
+ return 0;
|
|
26
|
+
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ public static float FeetToMeters(float feet){
|
|
30
|
+ float value =0;
|
|
31
|
+ if (feet > 0){
|
|
32
|
+ float n = feet *0.3048f;
|
|
33
|
+ value = n;
|
|
34
|
+ return value;
|
|
35
|
+ }
|
|
36
|
+ else{
|
|
37
|
+ }
|
|
38
|
+ return 0;
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ public static float MetersToFeet(float meters){
|
|
42
|
+ float value = 0;
|
|
43
|
+ if (meters > 0){
|
|
44
|
+ float n = meters * 3.28084f;
|
|
45
|
+ value = n;
|
|
46
|
+ return value;
|
|
47
|
+ }
|
|
48
|
+ else{
|
|
49
|
+ }
|
|
50
|
+ return 0;
|
|
51
|
+ }
|
7
|
52
|
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
|
53
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
54
|
+ float value =0;
|
|
55
|
+ if (celsius == 0){
|
|
56
|
+ float n = 32;
|
|
57
|
+ }
|
|
58
|
+ if (celsius !=0){
|
|
59
|
+ float n = celsius *1.8f + 32f;
|
|
60
|
+ value = n;
|
|
61
|
+ }
|
|
62
|
+ return Math.round(value);
|
|
63
|
+ }
|
9
|
64
|
|
10
|
|
- public static float FeetToMeters(float feet){}
|
|
65
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
11
|
66
|
|
12
|
|
- public static float MetersToFeet(float meters){}
|
|
67
|
+ float value = (fahrenheit - 32) * (5/9f);
|
13
|
68
|
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
|
69
|
+ return value;
|
|
70
|
+ }
|
15
|
71
|
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
|
72
|
+ public static float MphToKph(float mph){
|
|
73
|
+ float value =0;
|
|
74
|
+ if (mph > 0){
|
|
75
|
+ float n = mph * 1.60934f;
|
|
76
|
+ value = n;
|
|
77
|
+ return value;
|
|
78
|
+ }
|
|
79
|
+ else{
|
|
80
|
+ }
|
|
81
|
+ return 0;
|
17
|
82
|
|
18
|
|
- public static float MphToKph(float mph){}
|
|
83
|
+ }
|
19
|
84
|
|
20
|
|
- public static float KphToMph(float kph){}
|
|
85
|
+ public static float KphToMph(float kph){
|
|
86
|
+ float value =0;
|
|
87
|
+ if (kph > 0){
|
|
88
|
+ float n = kph * 0.621371f;
|
|
89
|
+ value = n;
|
|
90
|
+ return value;
|
|
91
|
+ }
|
|
92
|
+ else {
|
|
93
|
+ }
|
|
94
|
+ return 0;
|
|
95
|
+ }
|
21
|
96
|
}
|