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