diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/conversion.iml b/conversion.iml index 4b044f1..e0c2965 100644 --- a/conversion.iml +++ b/conversion.iml @@ -1,6 +1,6 @@ - + @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/src/main/java/ConversionTool.java b/src/main/java/ConversionTool.java index df73653..d77a0be 100644 --- a/src/main/java/ConversionTool.java +++ b/src/main/java/ConversionTool.java @@ -3,19 +3,59 @@ public class ConversionTool { public static void main(String[] args){} - public static float CentimetersToInches(float centimeters){} - - public static float InchesToCentimeters(float inches){} - - public static float FeetToMeters(float feet){} - - public static float MetersToFeet(float meters){} - - public static float CelsiusToFahrenheit(float celsius){} - - public static float FahrenheitToCelsius(float fahrenheit){} - - public static float MphToKph(float mph){} - - public static float KphToMph(float kph){} + public static float CentimetersToInches(float centimeters){ + if (centimeters < 0){ + return 0; + }else { + return (float) (centimeters * 0.393701); + } + } + + public static float InchesToCentimeters(float inches){ + if (inches < 0){ + return 0; + }else { + return (float) (inches * 2.54); + } + } + + public static float FeetToMeters(float feet){ + if (feet < 0){ + return 0; + }else { + return (float) (feet * 0.3048); + } + } + + public static float MetersToFeet(float meters){ + if (meters < 0){ + return 0; + }else { + return (float) (meters * 3.28084); + } + } + + public static float CelsiusToFahrenheit(float celsius){ + return (float)((celsius * (9.0/5.0)) + 32); + } + + public static float FahrenheitToCelsius(float fahrenheit){ + return (float) ((fahrenheit - 32) * (5.0/9.0)); + } + + public static float MphToKph(float mph){ + if (mph < 0){ + return 0; + }else { + return (float) (mph * 1.60934); + } + } + + public static float KphToMph(float kph){ + if (kph < 0){ + return 0; + }else { + return (float) (kph * 0.621371); + } + } } diff --git a/target/classes/ConversionTool.class b/target/classes/ConversionTool.class index 7d20ebc..719f595 100644 Binary files a/target/classes/ConversionTool.class and b/target/classes/ConversionTool.class differ