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