diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java index 4d7236e..471e86a 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java @@ -1,8 +1,65 @@ -/* + 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); + return value; + } + + public double cb(double value) { + value = 0; + value= Math.pow(value, 3); + return value; + } + 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; @@ -83,10 +140,18 @@ public static boolean isRadian ( double input){ if (Math.round(to180) == 57) { return true; } else { +<<<<<<< HEAD + } + return false; + } + */ + +/*======= }return false; } } } -*/ \ No newline at end of file +*/ + 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..6b20b8c --- /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 value; + value = scientific.tan(7); + if (value == 0.122784560) + { // + Assert.fail(); + } + } + @Test + public void testTanR() { + Scientific scientific = new Scientific(); + Double value; + value = scientific.tanR(0.10955952677); + if (value == Math.atan(.11)) + { // + Assert.fail(); + } + } + @Test + public void testCos(){ + Scientific scientific = new Scientific(); + Double value; + value = scientific.cos(-0.4480736161291702); + if (value == Math.cos(90.0)){ + Assert.fail(); + } + } + @Test + public void testCosR(){ + Scientific scientific = new Scientific(); + Double value; + value = scientific.cos(1.0); + if (value == Math.acos(-1.99)){ + 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 = new 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(); + } + } +}