From 03f3aac366949f4eb578f5707787b533efc185a5 Mon Sep 17 00:00:00 2001 From: charnaexw Date: Mon, 28 Jun 2021 01:01:23 -0400 Subject: [PATCH 1/2] I greyed out a lot of code but the code that is there should now be consistant with what you have. --- .../scientificcalculator/Scientific.java | 72 ++++++++++++--- .../scientific_calculator/ScientificTest.java | 92 +++++++++++++++++++ 2 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java index ad0ff18..17d8871 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java @@ -1,8 +1,63 @@ -/* + package com.zipcodewilmington.scientificcalculator; public class Scientific { + private static double value; + + public static Double tan (double value) { + value = 0; + value = Math.tan(value; + return value; + } + public Double tanR(double value) { + value = 0; + value = Math.atan(value); + return value; + } + + + public Double cos(double value) { + value = 0; + value = Math.cos(value); + return value; + } + + public double sin(double value) { + value = 0; + value = Math.sin(value); + } + + public double cb(double value) { + value = 0; + value= Math.pow(value, 3); + } + + public double sqrt(double value) { + value = 0; + value = Math.sqrt(value); + return value; + } + + public double squ(double value) { + value = 0; + value = Math.pow(value, 2); + return value + } + + + public double sinR(double value) { + value = 0; + value = Math.asin(value); + return value; + } + public double cosR(double value){ + value = 0; + value = Math.acos(value); + return value; + } +} + /*public double result; public static void main(String[] args) { int firstNum = 0; double value = 0.0; @@ -77,21 +132,14 @@ public static void main(String[] args) { default System.out.println("ERR"); } - */public static boolean isRadian ( double input){ + public static boolean isRadian ( double input){ double to180 = (input + ((180 / Math.PI) - input)); // 57 is 180 degrees rounded to whole number if (Math.round(to180) == 57) { return true; } else { - /*}return false; - - + } + return false; } - } -} -//<<<<<<< master -//======= -*/ - + */ -//>>>>>>> master diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java new file mode 100644 index 0000000..8853ac3 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java @@ -0,0 +1,92 @@ +package com.zipcodewilmington.scientific_calculator; + +import com.zipcodewilmington.scientificcalculator.CalculatorEngine; +import com.zipcodewilmington.scientificcalculator.Scientific; +import org.junit.Assert; +import org.junit.Test; + +public class ScientificTest { + @Test + public void testTan() { + Scientific scientific = new Scientific(); + Double result; + result = scientific.tan(-1.995200412208242); + if (result != 90.0) ; + { // + Assert.fail(); + } + } + @Test + public void testTanR() { + Scientific scientific = new Scientific(); + Double result; + result = scientific.tanR(-1.995200412208242); + if (result != 100) ; + { // + Assert.fail(); + } + } + @Test + public void testCos(){ + Scientific scientific = new Scientific(); + Double value; + value = scientific.cos(-1.995200412208242); + if value != scientific.cos(1.0){ + Assert.fail(); + } + } + @Test + public void testCosR(){ + Scientific scientific = new Scientific(); + Double value; + value = scientific.cos(-1.995200412208242); + if value != scientific.cos(1.0){ + Assert.fail(); + } + } + @Test + public void testSine (){ + Scientific scientific = new Scientific(); + double value; + value = scientific.sin(0.8939966636005579); + if value != scientific.sin(90){ + Assert.fail(); + } + } + @Test + public void testSineR (){ + Scientific scientific = new Scientific(); + double value; + value = scientific.sinR(8); + if value = scientific.sinR(5.0){ + Assert.fail(); + } + } + @Test + public void testCubed (){ + Scientific scientific = Scientific(); + double value; + value = scientific.cb(3); + if value = scientific.cb(10){ + Assert.fail(); + } + } + @Test + public void testSqrt (){ + Scientific scientific = new Scientific(); + double value; + value = scientific.sqrt(25); + if value != scientific.sqrt(5){ + Assert.fail(); + } + } + @Test + public void testSquare (){ + Scientific scientific = new Scientific(); + double value; + value = scientific.squ(5); + if value = scientific.squ(25){ + Assert.fail(); + } + } +} From d39280c3618c60c1c73c69f816310fe8cd78e668 Mon Sep 17 00:00:00 2001 From: charnaexw Date: Mon, 28 Jun 2021 02:06:17 -0400 Subject: [PATCH 2/2] I'm sleepy. --- .../scientificcalculator/Scientific.java | 6 ++-- .../scientific_calculator/ScientificTest.java | 30 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java index 17d8871..035a0c0 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java @@ -6,7 +6,7 @@ public class Scientific { public static Double tan (double value) { value = 0; - value = Math.tan(value; + value = Math.tan(value); return value; } @@ -26,11 +26,13 @@ public Double cos(double value) { public double sin(double value) { value = 0; value = Math.sin(value); + return value; } public double cb(double value) { value = 0; value= Math.pow(value, 3); + return value; } public double sqrt(double value) { @@ -42,7 +44,7 @@ public double sqrt(double value) { public double squ(double value) { value = 0; value = Math.pow(value, 2); - return value + return value; } diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java index 8853ac3..956b683 100644 --- a/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java +++ b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificTest.java @@ -10,8 +10,8 @@ public class ScientificTest { public void testTan() { Scientific scientific = new Scientific(); Double result; - result = scientific.tan(-1.995200412208242); - if (result != 90.0) ; + result = scientific.tan(0.87144798272); + if (result != Math.tan(7)) { // Assert.fail(); } @@ -19,9 +19,9 @@ public void testTan() { @Test public void testTanR() { Scientific scientific = new Scientific(); - Double result; - result = scientific.tanR(-1.995200412208242); - if (result != 100) ; + Double value; + value = scientific.tanR(0.10955952677); + if (value != Math.atan(.11)) { // Assert.fail(); } @@ -30,8 +30,8 @@ public void testTanR() { public void testCos(){ Scientific scientific = new Scientific(); Double value; - value = scientific.cos(-1.995200412208242); - if value != scientific.cos(1.0){ + value = scientific.cos(-0.4480736161291702); + if (value != Math.cos(90.0)){ Assert.fail(); } } @@ -39,8 +39,8 @@ public void testCos(){ public void testCosR(){ Scientific scientific = new Scientific(); Double value; - value = scientific.cos(-1.995200412208242); - if value != scientific.cos(1.0){ + value = scientific.cos(-1.99); + if (value != Math.acos(1.0)){ Assert.fail(); } } @@ -49,7 +49,7 @@ public void testSine (){ Scientific scientific = new Scientific(); double value; value = scientific.sin(0.8939966636005579); - if value != scientific.sin(90){ + if (value != scientific.sin(90)){ Assert.fail(); } } @@ -58,16 +58,16 @@ public void testSineR (){ Scientific scientific = new Scientific(); double value; value = scientific.sinR(8); - if value = scientific.sinR(5.0){ + if (value != scientific.sinR(5.0)){ Assert.fail(); } } @Test public void testCubed (){ - Scientific scientific = Scientific(); + Scientific scientific = new Scientific(); double value; value = scientific.cb(3); - if value = scientific.cb(10){ + if (value != scientific.cb(10)){ Assert.fail(); } } @@ -76,7 +76,7 @@ public void testSqrt (){ Scientific scientific = new Scientific(); double value; value = scientific.sqrt(25); - if value != scientific.sqrt(5){ + if (value != scientific.sqrt(5)){ Assert.fail(); } } @@ -85,7 +85,7 @@ public void testSquare (){ Scientific scientific = new Scientific(); double value; value = scientific.squ(5); - if value = scientific.squ(25){ + if (value != scientific.squ(25)){ Assert.fail(); } }