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