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..400d910 100644 --- a/conversion.iml +++ b/conversion.iml @@ -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..22ce713 100644 --- a/src/main/java/ConversionTool.java +++ b/src/main/java/ConversionTool.java @@ -1,21 +1,72 @@ + + public class ConversionTool { - public static void main(String[] args){} + public static void main(String[] args) { + } + + public static float CentimetersToInches(float centimeters) { + double inches_per_cm = 0.393701; + if (centimeters < 0) { + return 0; + } else { + return (float) (centimeters * inches_per_cm); + } + } - public static float CentimetersToInches(float centimeters){} + public static float InchesToCentimeters(float inches) { + double cm_per_inch = 2.54; + if (inches < 0) { + return 0; + } else { + return (float) (inches * cm_per_inch); + } + } - public static float InchesToCentimeters(float inches){} + public static float FeetToMeters(float feet) { + double Meters_Per_Foot = 0.3048; + if (feet < 0) { + return 0; + } else { - public static float FeetToMeters(float feet){} + return (float) (feet * Meters_Per_Foot); + } + } - public static float MetersToFeet(float meters){} + public static float MetersToFeet(float meters) { + double Feet_Per_Meter = 3.28084; + if (meters < 0) { + return 0; + } else { + return (float) (meters * Feet_Per_Meter); + } + } - public static float CelsiusToFahrenheit(float celsius){} + public static float CelsiusToFahrenheit(float celsius) { + return (float) ((celsius * 9/5) + 32); + } - public static float FahrenheitToCelsius(float fahrenheit){} + public static float FahrenheitToCelsius(float fahrenheit) { + double fahren_to_cels = (- 32) * 5/9; + return (float) ((fahrenheit - 32) * 5/9); + } - public static float MphToKph(float mph){} + public static float MphToKph(float mph) { + double KPH_PER_MPH = 1 / 0.621371; + if (mph < 0) { + return 0; + } else { + return (float) (KPH_PER_MPH * mph); + } + } - public static float KphToMph(float kph){} + public static float KphToMph(float kph) { + double MPH_PER_KPH = 0.621371; + if (kph < 0) { + return 0; + } else { + return (float) (kph * MPH_PER_KPH); + } + } } diff --git a/target/classes/ConversionTool.class b/target/classes/ConversionTool.class index 7d20ebc..6ec2ce1 100644 Binary files a/target/classes/ConversionTool.class and b/target/classes/ConversionTool.class differ