|
@@ -1,21 +1,75 @@
|
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 centimeters){
|
|
8
|
+ if (centimeters >= 0){
|
|
9
|
+ centimeters = centimeters * (float) 0.393701;
|
7
|
10
|
|
8
|
|
- public static float InchesToCentimeters(float inches){}
|
|
11
|
+ }else{
|
|
12
|
+ return 0;
|
|
13
|
+ }
|
|
14
|
+ return centimeters;
|
|
15
|
+ }
|
9
|
16
|
|
10
|
|
- public static float FeetToMeters(float feet){}
|
|
17
|
+ public static float InchesToCentimeters(float inches){
|
|
18
|
+ if (inches >= 0){
|
|
19
|
+ inches = inches * (float)2.54;
|
|
20
|
+ }else{
|
|
21
|
+ return 0;
|
|
22
|
+ }
|
|
23
|
+ return inches;
|
|
24
|
+ }
|
11
|
25
|
|
12
|
|
- public static float MetersToFeet(float meters){}
|
|
26
|
+ public static float FeetToMeters(float feet){
|
|
27
|
+ if (feet > 0){
|
|
28
|
+ feet = feet * (float)0.3048;
|
|
29
|
+ }else{
|
|
30
|
+ return 0;
|
|
31
|
+ }
|
|
32
|
+ return feet;
|
|
33
|
+ }
|
13
|
34
|
|
14
|
|
- public static float CelsiusToFahrenheit(float celsius){}
|
|
35
|
+ public static float MetersToFeet(float meters){
|
|
36
|
+ if (meters > 0){
|
|
37
|
+ meters = meters * (float)3.28084;
|
|
38
|
+ }else{
|
|
39
|
+ return 0;
|
|
40
|
+ }
|
|
41
|
+ return meters;
|
|
42
|
+ }
|
15
|
43
|
|
16
|
|
- public static float FahrenheitToCelsius(float fahrenheit){}
|
|
44
|
+ public static float CelsiusToFahrenheit(float celsius){
|
|
45
|
+ if(celsius >= 0){
|
|
46
|
+ celsius = (celsius) * (float)1.8 + 32;
|
|
47
|
+ }
|
|
48
|
+ return celsius;
|
|
49
|
+ }
|
17
|
50
|
|
18
|
|
- public static float MphToKph(float mph){}
|
|
51
|
+ public static float FahrenheitToCelsius(float fahrenheit){
|
|
52
|
+ if (fahrenheit > 0){
|
|
53
|
+ fahrenheit = (fahrenheit - 32) / (float)(1.8);
|
|
54
|
+ }
|
|
55
|
+ return fahrenheit;
|
|
56
|
+ }
|
19
|
57
|
|
20
|
|
- public static float KphToMph(float kph){}
|
|
58
|
+ public static float MphToKph(float mph){
|
|
59
|
+ if(mph > 0){
|
|
60
|
+ mph = mph * (float)1.60934;
|
|
61
|
+ }else{
|
|
62
|
+ return 0;
|
|
63
|
+ }
|
|
64
|
+ return mph;
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ public static float KphToMph(float kph){
|
|
68
|
+ if(kph > 0){
|
|
69
|
+ kph = kph * (float)0.621371;
|
|
70
|
+ }else{
|
|
71
|
+ return 0;
|
|
72
|
+ }
|
|
73
|
+ return kph;
|
|
74
|
+ }
|
21
|
75
|
}
|