diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 3c5f7fa..7ec525c 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,27 +1,11 @@ - - - - - - - - - - - - - - - - + - diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index dfca8c4..78226aa 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,42 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + 1.8 @@ -37,6 +84,17 @@ + + + + + + + \ No newline at end of file diff --git a/conversion.iml b/conversion.iml index 4b044f1..0ddf51c 100644 --- a/conversion.iml +++ b/conversion.iml @@ -1,11 +1,10 @@ - + - diff --git a/src/main/java/ConversionTool.java b/src/main/java/ConversionTool.java deleted file mode 100644 index df73653..0000000 --- a/src/main/java/ConversionTool.java +++ /dev/null @@ -1,21 +0,0 @@ -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){} -} diff --git a/src/main/java/newTool.java b/src/main/java/newTool.java new file mode 100644 index 0000000..5f79aa8 --- /dev/null +++ b/src/main/java/newTool.java @@ -0,0 +1,78 @@ +import java.util.Scanner; + +public class newTool { + + + public static void main(String[] args){ + } + + public float centimetersToInches(float centimeters){ + if (centimeters<0){ + return 0; + } + float inches = (float) (((centimeters / 2.54) * 100 ) / 100.0); + return (inches ); + } + + public static float InchesToCentimeters(float inches){ + if (inches<0){ + return 0; + } + float centimeters = (float) (((inches * 2.54) * 100 )/ 100.0 ); + return (centimeters ); + } + + public static float FeetToMeters(float feet) { + if (feet<0){ + return 0; + } + float meters = (float) (((feet * 0.3048) * 100) / 100.0); + return (meters); + + } + + + public static float MetersToFeet(float meters){ + if (meters<0){ + return 0; + } + float feet = (float) (((meters / 0.3048) * 100) / 100.0); + return (feet); + } + + + + public static float CelsiusToFahrenheit(float celsius){ + float Fahrenheit = (float) ((((celsius * 9/5.0) +32) * 100) / 100.0); + return (Fahrenheit); + + } + + + public static float FahrenheitToCelsius(float fahrenheit){ + float celsius = (float) ((((fahrenheit -32) * 5/9.0) * 100) / 100.0); + return (celsius); + + } + + public static float MphToKph(float mph){ + if (mph<0){ + return 0; + } + float Kph = (float) (((mph * 1.60934) * 100) / 100.0); + return (Kph); + + } + + public static float KphToMph(float kph){ + if (kph<0){ + return 0; + } + float mph = (float) (((kph / 1.60934) * 100) / 100.0); + return (mph); + } + + +} + + diff --git a/src/test/java/ConversionToolSpec.java b/src/test/java/ConversionToolSpec.java index 5bbfb07..351b032 100644 --- a/src/test/java/ConversionToolSpec.java +++ b/src/test/java/ConversionToolSpec.java @@ -3,110 +3,114 @@ public class ConversionToolSpec { + newTool newTool = new newTool(); + @Test public void shouldConvertCentimetersToInches() { - float inches = ConversionTool.CentimetersToInches(2f); + + float inches = newTool.centimetersToInches(2f); assertEquals(0.7874f, inches, 0.001); } @Test public void shouldConvertZeroCentimetersToZeroInches() { - float inches = ConversionTool.CentimetersToInches(0); + float inches = newTool.centimetersToInches(0); assertEquals(0, inches, 0.0); } @Test public void shouldConvertNegativeCentimetersToZeroInches() { - float inches = ConversionTool.CentimetersToInches(-5); + float inches = newTool.centimetersToInches(-5); assertEquals(0, inches, 0.0); } @Test public void shouldConvertInchesToCentimeters() { - float centimeters = ConversionTool.InchesToCentimeters(4f); + float centimeters = newTool.InchesToCentimeters(4f); assertEquals(10.16f, centimeters, 0.001); } @Test public void shouldConvertZeroInchesToZeroCentimeters() { - float centimeters = ConversionTool.InchesToCentimeters(0); + float centimeters = newTool.InchesToCentimeters(0); assertEquals(0, centimeters, 0.0); } @Test public void shouldConvertNegativeInchesToZeroCentimeters() { - float centimeters = ConversionTool.InchesToCentimeters(-5); + float centimeters = newTool.InchesToCentimeters(-5); assertEquals(0, centimeters, 0.0); } @Test public void shouldConvertFeetToMeters() { - float meters = ConversionTool.FeetToMeters(5f); + float meters = newTool.FeetToMeters(5f); assertEquals(1.524f, meters, 0.001); } @Test public void shouldConvertZeroFeetToZeroMeters() { - float meters = ConversionTool.FeetToMeters(0); + float meters = newTool.FeetToMeters(0); assertEquals(0, meters, 0.0); } @Test public void shouldConvertNegativeFeetToZeroMeters() { - float meters = ConversionTool.FeetToMeters(-10); + float meters = newTool.FeetToMeters(-10); assertEquals(0, meters, 0.0); } @Test public void shouldConvertMetersToFeet() { - float feet = ConversionTool.MetersToFeet(9f); + float feet = newTool.MetersToFeet(9f); assertEquals(29.5276f, feet, 0.001); } @Test public void shouldConvertZeroMetersToZeroFeet() { - float feet = ConversionTool.MetersToFeet(0); + float feet = newTool.MetersToFeet(0); assertEquals(0, feet, 0.0); } @Test public void shouldConvertNegativeMetersToZeroFeet() { - float feet = ConversionTool.MetersToFeet(-10); + float feet = newTool.MetersToFeet(-10); assertEquals(0, feet, 0.0); } - @Test - public void shouldConvertFahrenheitToCelsius() { - float celsius = ConversionTool.FahrenheitToCelsius(80); - assertEquals(26.67, celsius, 0.01); - } + @Test + public void shouldConvertFahrenheitToCelsius() { + float celsius = newTool.FahrenheitToCelsius(80); + assertEquals(26.67, celsius, 0.01); + } + @Test public void shouldConvertCelsiusToFahrenheit() { - float fahrenheit = ConversionTool.CelsiusToFahrenheit(26.67f); + float fahrenheit = newTool.CelsiusToFahrenheit(26.67f); assertEquals(80, fahrenheit, 0.01); } @Test public void shouldConvertMphToKph(){ - float kph = ConversionTool.MphToKph(24f); + float kph = newTool.MphToKph(24f); assertEquals(38.62, kph, 0.01); } @Test public void shouldConvertZeroMphToZeroKph(){ - float kph = ConversionTool.MphToKph(0f); + float kph = newTool.MphToKph(0f); assertEquals(0, kph, 0.0); } @Test public void shouldConvertNegativeMphToZeroKph(){ - float kph = ConversionTool.MphToKph(-50f); + float kph = newTool.MphToKph(-50f); assertEquals(0, kph, 0.0); } @Test public void shouldConvertKphToMph(){ - float mph = ConversionTool.KphToMph(6.44f); + float mph = newTool.KphToMph(6.44f); assertEquals(4, mph, 0.01); } @Test public void shouldConvertZeroKphToZeroMph(){ - float mph = ConversionTool.KphToMph(0f); + float mph = newTool.KphToMph(0f); assertEquals(0, mph, 0.0); } @Test public void shouldConvertNegativeKphToZeroMph(){ - float mph = ConversionTool.KphToMph(-50f); + float mph = newTool.KphToMph(-50f); assertEquals(0, mph, 0.0); } diff --git a/target/classes/ConversionTool.class b/target/classes/ConversionTool.class deleted file mode 100644 index 7d20ebc..0000000 Binary files a/target/classes/ConversionTool.class and /dev/null differ diff --git a/target/test-classes/ConversionToolSpec.class b/target/test-classes/ConversionToolSpec.class index 2cc6d49..7aa389a 100644 Binary files a/target/test-classes/ConversionToolSpec.class and b/target/test-classes/ConversionToolSpec.class differ