diff --git a/Hello.txt b/Hello.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/README.md b/README.md
index 8402302c..40ce4afe 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# ScientificCalculator (maven) ZCW
-
+## James
## Description
In this project your team will build a small app to function as a calculator. This app will be built in Java, and will use the topics and techniques discussed during the week.
@@ -63,7 +63,7 @@ Each operation should automatically update the display
- Ln (natural logarithm)
- ex (inverse natural logarithm)
- Factorial function
-
+//
### Custom Features
diff --git a/pom.xml b/pom.xml
index e7cb4f6b..471b8841 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,18 @@
com.zipcodewilmington
scientific_calculator
1.0-SNAPSHOT
+
+
+ junit
+ junit
+<<<<<<< HEAD
+ RELEASE
+=======
+ 4.12
+>>>>>>> fb9393f6415e572d2b4750a4662a151dc5895047
+ test
+
+
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/BasicMath.java b/src/main/java/com/zipcodewilmington/scientificcalculator/BasicMath.java
new file mode 100644
index 00000000..986665f0
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/BasicMath.java
@@ -0,0 +1,35 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class BasicMath {
+ // two operator methods
+ public static Double addition (Double numberOne, Double numberTwo) {
+ return (numberOne + numberTwo);
+ }
+ public static Double subtraction (Double numberOne, Double numberTwo) {
+ return numberOne - numberTwo;
+ }
+ public static Double multiplication (Double numberOne, Double numberTwo) {
+ return numberOne * numberTwo;
+ }
+ public static Double division (Double numberOne, Double numberTwo) {
+ return numberOne / numberTwo;
+ }
+ public static Double exponent (Double numberOne, Double numberTwo){
+ return Math.pow(numberOne, numberTwo);
+ }
+ // one operator methods
+
+ public static Double square (Double numberOne) {
+ return numberOne * numberOne;
+ }
+ public static Double squareroot (Double numberOne){
+ return (Math.sqrt(numberOne));
+ }
+ public static Double inverse(Double numberOne){
+ return 1/numberOne;
+ }
+}
+
+
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/BoxMaker.java b/src/main/java/com/zipcodewilmington/scientificcalculator/BoxMaker.java
new file mode 100644
index 00000000..d4587d08
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/BoxMaker.java
@@ -0,0 +1,59 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.util.ArrayList;
+
+public class BoxMaker {
+ private int width;
+
+ public BoxMaker() {
+ width = 30;
+ }
+
+ public BoxMaker(int initialWidth)
+ {
+ width = initialWidth;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int newWidth)
+ {
+ if(newWidth > 3 && newWidth < 151)
+ {
+ width = newWidth;
+ }
+ }
+
+ public String draw(String ... input) {
+ StringBuilder output = new StringBuilder();
+
+ output.append("╔");
+ for (int i = 0; i < width - 2; i++) {
+ output.append("═");
+ }
+ output.append("╗\n");
+
+ for (String element : input) {
+ String line = "";
+ StringBuilder lineFormat = new StringBuilder();
+ lineFormat.append("%");
+ lineFormat.append(width - 2);
+ lineFormat.append("s");
+
+ line = String.format(lineFormat.toString(), element);
+ output.append("║");
+ output.append(line);
+ output.append("║\n");
+ }
+
+ output.append("╚");
+ for (int i = 0; i < width - 2; i++) {
+ output.append("═");
+ }
+ output.append("╝\n");
+
+ return output.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
index 83f0e97f..f874f1e3 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
@@ -23,10 +23,18 @@ public static String getStringInput(String prompt) {
}
public static Integer getIntegerInput(String prompt) {
- return null;
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ String userInput;
+ userInput = scanner.nextLine();
+ return Integer.parseInt(userInput);
}
public static Double getDoubleInput(String prompt) {
- return null;
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ String userInput;
+ userInput = scanner.nextLine();
+ return Double.parseDouble(userInput);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ConversionMath.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ConversionMath.java
new file mode 100644
index 00000000..225c6ef9
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ConversionMath.java
@@ -0,0 +1,27 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class ConversionMath {
+
+ public static Double feetToMeters (Double numberOne) {
+ return numberOne / 3.2810;
+ }
+ public static Double metersToFeet (Double numberOne) {
+ return numberOne * 3.28084;
+ }
+ public static Double poundsToKilos(Double numberOne) {
+ return numberOne / 2.205;
+ }
+ public static Double kilosToPounds(Double numberOne) {
+ return numberOne * 2.205;
+ }
+ public static Double fahrenheitToCelsius (Double numberOne) {
+ return ((numberOne - 32) * 5 / 9);
+ }
+ public static Double celsiusToFahrenheit (Double numberOne) {
+ return ((numberOne * 9 / 5) + 32);
+ }
+
+
+}
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Display.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Display.java
new file mode 100644
index 00000000..d85ce2be
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Display.java
@@ -0,0 +1,164 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import javax.swing.*;
+import java.io.DataInput;
+
+public class Display {
+ private int displayWidth;
+ private BoxMaker displayBox;
+ private Double currentValue;
+// private String currentOperation; Moving to input
+ public enum Modes { BINARY, OCTAL, DEC, HEX }
+ private Modes mode;
+ private Boolean isRadians;
+ Boolean error;
+
+ public Display()
+ {
+ currentValue = 0.0;
+ mode = Modes.DEC;
+ displayWidth = 50;
+ displayBox = new BoxMaker(displayWidth);
+ isRadians = false;
+ error = false;
+ }
+
+ public void setDisplay(Double inputValue)
+ {
+ if (inputValue.isNaN() || inputValue.isInfinite())
+ {
+ error = true;
+ }
+ else {
+ currentValue = inputValue;
+ }
+ }
+
+ public Double getDisplay()
+ {
+ return currentValue;
+ }
+
+ // Future implimentation, running out of time to format correctly with DEG/RAD and
+ // BINARY/OCTAL/HEX left-justification on display
+ public void setDisplayWidth(int newWidth)
+ {
+ displayWidth = newWidth;
+ }
+
+ public String update() {
+ String output = "";
+ String radianLine = "";
+ String valueLine = "";
+ String baseLine = "";
+
+ if (error) {
+ radianLine = String.format("%-46s", "ERR");
+ valueLine = "ERR ";
+ baseLine = String.format("%-46s", "ERR");
+ output = displayBox.draw(radianLine, valueLine, baseLine);
+ } else {
+ if (isRadians == true) {
+ radianLine = String.format("%-46s", "RAD");
+ } else {
+ radianLine = " ";
+ }
+
+
+ // This needs to be fixed
+ if (mode == Modes.BINARY) {
+ baseLine = String.format("%-46s", "BIN");
+ valueLine = Integer.toBinaryString(currentValue.intValue()) + " ";
+ } else if (mode == Modes.OCTAL) {
+ baseLine = String.format("%-46s", "OCTAL");
+ valueLine = Integer.toOctalString(currentValue.intValue()) + " ";
+ } else if (mode == Modes.DEC) {
+ if (currentValue % 1 == 0) // No decimal
+ {
+ valueLine = Integer.toString(currentValue.intValue()) + " ";
+ } else {
+ valueLine = Double.toString(currentValue) + " ";
+ }
+ } else if (mode == Modes.HEX) {
+ baseLine = String.format("%-46s", "HEX");
+ valueLine = Integer.toHexString(currentValue.intValue()) + " ";
+ }
+ }
+
+ output = displayBox.draw(radianLine, valueLine, baseLine);
+ Console.println("%s", output);
+ return output;
+ }
+
+ public void setMode(Modes newMode)
+ {
+ mode = newMode;
+ }
+
+ public void setMode() {
+ switch (mode)
+ {
+ case DEC:
+ setMode(Modes.BINARY);
+ break;
+ case BINARY:
+ setMode(Modes.OCTAL);
+ break;
+ case OCTAL:
+ setMode(Modes.HEX);
+ break;
+ case HEX:
+ setMode(Modes.DEC);
+ break;
+ }
+
+ // Considering updating currentVal here, but makes math more difficult
+ // since Math assumes decimal math.
+ }
+
+ public Modes getMode()
+ {
+ return mode;
+ }
+
+ public void clear() {
+ currentValue = 0.0;
+ error = false;
+ isRadians = false;
+ mode = Modes.DEC;
+ // Send a command to input to remove last operation and last value input
+ }
+
+ public void invSign()
+ {
+ currentValue *= -1.0;
+ }
+
+ public Double absoluteValue()
+ {
+ if(currentValue < 0)
+ {
+ return currentValue * -1;
+ }
+ else
+ {
+ return currentValue;
+ }
+ }
+
+ public void toggleRadians()
+ {
+ isRadians = !isRadians;
+ }
+
+ public Boolean getIsRadians()
+ {
+ return isRadians;
+ }
+
+ public Boolean getErr() {
+ return error;
+ }
+
+ // Make a toggle to switch from normal notation to scientific notation
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/InputErrorHandler.java b/src/main/java/com/zipcodewilmington/scientificcalculator/InputErrorHandler.java
new file mode 100644
index 00000000..b7e70e33
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/InputErrorHandler.java
@@ -0,0 +1,64 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InputErrorHandler {
+ private static List listOfValid = new ArrayList();
+
+ public InputErrorHandler()
+ {
+ }
+
+ public static Boolean validOp(String op)
+ {
+ return listOfValid.contains(op);
+ }
+
+ public static Boolean validNumber(String in)
+ {
+ Boolean isANumber = true;
+
+ try
+ {
+ Double num = Double.parseDouble(in);
+ } catch (NumberFormatException error) {
+ isANumber = false;
+ }
+
+ return isANumber;
+ }
+
+ static {
+ listOfValid.add("c"); //
+ listOfValid.add("m+"); //
+ listOfValid.add("m"); //
+ listOfValid.add("mc"); //
+ listOfValid.add("inv"); //
+ listOfValid.add("+");
+ listOfValid.add("-");
+ listOfValid.add("*");
+ listOfValid.add("/");
+ listOfValid.add("exp");
+ listOfValid.add("sq"); //
+ listOfValid.add("sqrt"); //
+ listOfValid.add("mode"); //
+ listOfValid.add("bin"); //
+ listOfValid.add("oct"); //
+ listOfValid.add("dec"); //
+ listOfValid.add("hex"); //
+ listOfValid.add("rad"); //
+ listOfValid.add("log");
+ listOfValid.add("invlog");
+ listOfValid.add("nlog");
+ listOfValid.add("invnlog");
+ listOfValid.add("!");
+ listOfValid.add("fib");
+ listOfValid.add("mtf");
+ listOfValid.add("ftm");
+ listOfValid.add("ptk");
+ listOfValid.add("ktp");
+ listOfValid.add("ftc");
+ listOfValid.add("ctf");
+ }
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Logarithm.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Logarithm.java
new file mode 100644
index 00000000..b7f38bb6
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Logarithm.java
@@ -0,0 +1,48 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class Logarithm {
+
+ Double x;
+
+ public Logarithm() {
+
+ x =0.0;
+
+ }
+
+ public static Double Log(Double x) {
+
+ if (x<=0)
+ return 0.0;
+
+ return Math.log10(x);
+
+ }
+
+ public static Double InvLog(Double x) {
+
+ return Math.pow(10,x);
+
+ }
+
+ public static Double NLog(Double x) {
+
+ if (x<=0)
+ return 0.0;
+
+ return Math.log(x);
+
+ }
+
+ public static Double InvNLog(Double x) {
+
+ return (Math.pow(Math.exp(1.0), x));
+
+ }
+
+
+}
+
+
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
index 5f421325..40dba370 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
@@ -2,16 +2,16 @@
/**
* Created by leon on 2/9/18.
+ * James, Sandy and Zanetta version
*/
public class MainApplication {
+ private static Prompt prompt = new Prompt();
+
public static void main(String[] args) {
- Console.println("Welcome to my calculator!");
- String s = Console.getStringInput("Enter a string");
- Integer i = Console.getIntegerInput("Enter an integer");
- Double d = Console.getDoubleInput("Enter a double.");
+ Console.println("Welcome to Mr. Math!");
+ Console.println("To see a valid list of commands, type 'menu' at any time");
+ Console.println("When you are finish with Mr. Math, feel free to quit by entering ':q'");
- Console.println("The user input %s as a string", s);
- Console.println("The user input %s as a integer", i);
- Console.println("The user input %s as a d", d);
+ prompt.start();
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Memory.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Memory.java
new file mode 100644
index 00000000..f8bfb308
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Memory.java
@@ -0,0 +1,21 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class Memory {
+ private static Double value;
+
+ public Memory() {
+ value = 0.0;
+ }
+
+ public static Double getMemory() {
+ return value;
+ }
+
+ public static void setMemory(Double input) {
+ value = input;
+ }
+
+ public static void resetMemory() {
+ value = 0.0;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Menu.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Menu.java
new file mode 100644
index 00000000..05af54f7
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Menu.java
@@ -0,0 +1,50 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class Menu
+{
+ public void Menu(){
+ }
+
+ public static String callMenu()
+ {
+ BoxMaker menuBox = new BoxMaker(120);
+
+ return menuBox.draw(
+ String.format("%-100s", "c | Resets the display to 0"),
+ String.format("%-100s", "m | Remember display"),
+ String.format("%-100s", "m+ | Store memory"),
+ String.format("%-100s", "mc | Reset memory to 0"),
+ String.format("%-100s", "inv | Invert the sign of the display value"),
+ String.format("%-100s", "bin | Set mode to binary"),
+ String.format("%-100s", "oct | Set mode to octal"),
+ String.format("%-100s", "dec | Set mode to decimal"),
+ String.format("%-100s", "hex | Set mode to hexadecimal"),
+ String.format("%-100s", "mode | Invert the sign of the display value"),
+ String.format("%-100s", "+ | Adds the display value to next input"),
+ String.format("%-100s", "- | Subtracts the next input from display value"),
+ String.format("%-100s", "* | Multiplies display value with next input"),
+ String.format("%-100s", "/ | Divides display value by next input"),
+ String.format("%-100s", "exp | Display value to power of next input"),
+ String.format("%-100s", "sq | Display value multiplied by itself"),
+ String.format("%-100s", "sqrt | Square root of display value"),
+ String.format("%-100s", "rad | Use Radians for Trigonometry"),
+ String.format("%-100s", "sin | Sine of display value"),
+ String.format("%-100s", "cos | Cosine of display value"),
+ String.format("%-100s", "tan | Tangent of display value"),
+ String.format("%-100s", "invsin | Inverse sine of display value"),
+ String.format("%-100s", "invcos | Inverse cosine of display value"),
+ String.format("%-100s", "invtan | Inverse tangent of display value"),
+ String.format("%-100s", "log | Log of display value"),
+ String.format("%-100s", "invlog | Inverse log of display value"),
+ String.format("%-100s", "nlog | N-log of display value"),
+ String.format("%-100s", "invnlog | Inverse N-log of display value"),
+ String.format("%-100s", "! | Factorial of display value"),
+ String.format("%-100s", "fib | Fibonacci of display value"),
+ String.format("%-100s", "mtf | Meters to feet"),
+ String.format("%-100s", "ftm | Feet to meters"),
+ String.format("%-100s", "ktp | Kilograms to pounds"),
+ String.format("%-100s", "ptk | Pounds to kilograms"),
+ String.format("%-100s", "ctf | Celsius to Farenheit"),
+ String.format("%-100s", "ftc | Farenheit to Celsius"));
+ }
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Operation.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Operation.java
new file mode 100644
index 00000000..316d3634
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Operation.java
@@ -0,0 +1,38 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class Operation {
+ public static Boolean isSetting(String op) {
+ if ("c".equals(op) || "m".equals(op) || "m+".equals(op) ||
+ "mc".equals(op) || "rad".equals(op)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static Boolean isUnary(String op)
+ {
+ if ("inv".equals(op) || "bin".equals(op) || "oct".equals(op) || "dec".equals(op) || "hex".equals(op) ||
+ "mode".equals(op) || "sq".equals(op) || "sqrt".equals(op) || "sin".equals(op) || "cos".equals(op) ||
+ "tan".equals(op) || "invsin".equals(op) || "invcos".equals(op) || "invtan".equals(op) || "log".equals(op) ||
+ "nlog".equals(op) || "invlog".equals(op) || "invnlog".equals(op) || "!".equals(op) || "fib".equals(op) ||
+ "ftm".equalsIgnoreCase(op) || "mtf".equalsIgnoreCase(op) || "ptk".equalsIgnoreCase(op) ||
+ "ktp".equalsIgnoreCase(op) || "ftc".equalsIgnoreCase(op) || "ctf".equalsIgnoreCase(op))
+ {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static Boolean isBinary(String op)
+ {
+ if("+".equals(op) || "-".equals(op) || "*".equals(op) ||
+ "/".equals(op) || "exp".equals(op)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/OtherFunctions.java b/src/main/java/com/zipcodewilmington/scientificcalculator/OtherFunctions.java
new file mode 100644
index 00000000..836fc753
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/OtherFunctions.java
@@ -0,0 +1,41 @@
+package com.zipcodewilmington.scientificcalculator;
+
+
+public class OtherFunctions {
+
+ Double x;
+
+ public OtherFunctions() {
+
+ x = 0.0;
+ }
+
+ public static Double Fact(Double x){
+
+ if (x<0)
+ return 0.0;
+
+ if (x == 0 || x == 1)
+ return 1.0;
+
+ return x*Fact(x-1);
+ }
+
+ public static Double Fibon(Double x) {
+
+ if (x<0)
+ return 0.0;
+
+ if (0<=x && x<=1)
+ return x;
+
+ return Fibon(x-1) + Fibon(x-2);
+
+
+ }
+
+}
+
+
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Prompt.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Prompt.java
new file mode 100644
index 00000000..7b158a4d
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Prompt.java
@@ -0,0 +1,121 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import sun.rmi.runtime.Log;
+
+import javax.print.attribute.standard.MediaSize;
+
+public class Prompt {
+ private String inputOperation;
+ private String previousOperation;
+ private Double inputValue;
+ private String message;
+ private Display display = new Display();
+ private Memory memory = new Memory();
+
+ public Prompt() {
+ inputOperation = "";
+ previousOperation = "";
+ inputValue = 0.0;
+ message = "";
+ }
+
+ public void start() {
+ display.update();
+ parseInput(Console.getStringInput("> "));
+ }
+
+ public void parseInput(String s) {
+
+ if (InputErrorHandler.validNumber(s)) {
+ display.setDisplay(Double.parseDouble(s));
+ } else if (s.equalsIgnoreCase("menu")) {
+ Console.println(Menu.callMenu());
+ } else if (!InputErrorHandler.validOp(s)) {
+ Console.println("Invalid input, 'menu' will list commands");
+ } else if (Operation.isSetting(s)) {
+ if (s.equalsIgnoreCase("c")) {
+ display.clear();
+ } else if (s.equalsIgnoreCase("m")) {
+ display.setDisplay(memory.getMemory());
+ } else if (s.equalsIgnoreCase("m+")) {
+ memory.setMemory(display.getDisplay());
+ } else if (s.equalsIgnoreCase("mc")) {
+ memory.setMemory(0.0);
+ } else if (s.equalsIgnoreCase("rad")) {
+ display.toggleRadians();
+ }
+ } else if (Operation.isUnary(s)) {
+ if (s.equalsIgnoreCase("inv")) {
+ display.invSign();
+ } else if (s.equalsIgnoreCase("sq")) {
+ display.setDisplay(BasicMath.square(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("sqrt")) {
+ display.setDisplay(BasicMath.squareroot(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("mode")) {
+ display.setMode();
+ } else if (s.equalsIgnoreCase("bin")) {
+ display.setMode(Display.Modes.BINARY);
+ } else if (s.equalsIgnoreCase("oct")) {
+ display.setMode(Display.Modes.OCTAL);
+ } else if (s.equalsIgnoreCase("dec")) {
+ display.setMode(Display.Modes.DEC);
+ } else if (s.equalsIgnoreCase("hex")) {
+ display.setMode(Display.Modes.HEX);
+ } else if (s.equalsIgnoreCase("log")) {
+ display.setDisplay(Logarithm.Log(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("invlog")) {
+ display.setDisplay(Logarithm.InvLog(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("nlog")) {
+ display.setDisplay(Logarithm.NLog(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("invnlog")) {
+ display.setDisplay(Logarithm.InvNLog(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("!")) {
+ display.setDisplay(OtherFunctions.Fact(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("fib")) {
+ display.setDisplay(OtherFunctions.Fibon(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("ftm")) {
+ display.setDisplay(ConversionMath.feetToMeters(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("mtf")) {
+ display.setDisplay(ConversionMath.metersToFeet(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("ptk")) {
+ display.setDisplay(ConversionMath.poundsToKilos(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("ktp")) {
+ display.setDisplay(ConversionMath.kilosToPounds(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("ctf")) {
+ display.setDisplay(ConversionMath.celsiusToFahrenheit(display.getDisplay()));
+ } else if (s.equalsIgnoreCase("ftc")) {
+ display.setDisplay(ConversionMath.fahrenheitToCelsius(display.getDisplay()));
+ }
+ } else {
+ Boolean success = true;
+ Double secondValue = 0.0;
+ try
+ {
+ secondValue = Console.getDoubleInput("Enter a second value: ");
+ }
+ catch(NumberFormatException error)
+ {
+ success = false;
+ Console.println("Invalid input");
+ }
+
+ if(s.equalsIgnoreCase("+")) {
+ display.setDisplay(BasicMath.addition(display.getDisplay(), secondValue));
+ } else if(s.equalsIgnoreCase("-"))
+ {
+ display.setDisplay(BasicMath.subtraction(display.getDisplay(), secondValue));
+ } else if(s.equalsIgnoreCase("*"))
+ {
+ display.setDisplay(BasicMath.multiplication(display.getDisplay(), secondValue));
+ } else if(s.equalsIgnoreCase("/"))
+ display.setDisplay(BasicMath.division(display.getDisplay(), secondValue));
+ else if(s.equalsIgnoreCase("exp"))
+ {
+ display.setDisplay(BasicMath.exponent(display.getDisplay(), secondValue));
+ }
+ }
+
+ display.update();
+ parseInput(Console.getStringInput("> "));
+ }
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Trig.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Trig.java
new file mode 100644
index 00000000..16157920
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Trig.java
@@ -0,0 +1,101 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class Trig {
+
+ Double x;
+
+ public Trig() {
+
+ x = 0.0;
+ }
+
+ public static Double Sin(Double x, String unitOfMeasurement)
+ {
+ if("DEG".equals(unitOfMeasurement))
+ {
+ if (x >= 360) {
+ x = x % 360;
+ }
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+
+ return Math.sin(radians);
+
+ }
+ else
+ // sin() method to get the value
+ return Math.sin(x);
+
+ }
+
+
+
+
+ public static Double Cos(Double x, String unitOfMeasurement) {
+ if ("DEG".equals(unitOfMeasurement)) {
+
+ if (x >= 360) {
+ x = x % 360;
+ }
+
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+ return Math.cos(radians);
+ }
+
+ else
+
+ // cos() method to get the value
+ return Math.cos(x);
+
+ }
+
+ public static Double Tan(Double x, String unitOfMeasurement) {
+
+ if ("DEG".equals(unitOfMeasurement)) {
+
+ if (x >= 360) {
+ x = x % 360;
+ }
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+ return Math.tan(radians);
+ }
+
+ else
+
+ // tan() method to get the value
+ return Math.tan(x);
+
+ }
+
+ public static Double InvSin(Double x)
+ {
+
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+
+ // InvSin() method to get the value
+ return Math.toDegrees(Math.asin(x));
+ }
+
+ public static Double InvCos(Double x)
+ {
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+
+ // InvCos() method to get the value
+ return Math.toDegrees(Math.acos(x));
+
+ }
+
+ public static Double InvTan(Double x)
+ {
+ // convert degrees to radians
+ double radians = Math.toRadians(x);
+
+ // InvTan() method to get the value
+ return Math.toDegrees(Math.atan(x));
+ }
+
+ }
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ValidOperations.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ValidOperations.java
new file mode 100644
index 00000000..d6158c79
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ValidOperations.java
@@ -0,0 +1,48 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ValidOperations
+{
+ private static List listOfValid = new ArrayList();
+
+ public ValidOperations()
+ {
+ listOfValid.add("c");
+ listOfValid.add("m+");
+ listOfValid.add("m");
+ listOfValid.add("mc");
+ listOfValid.add("inv");
+ listOfValid.add("+");
+ listOfValid.add("-");
+ listOfValid.add("*");
+ listOfValid.add("/");
+ listOfValid.add("exp");
+ listOfValid.add("sq");
+ listOfValid.add("sqrt");
+ listOfValid.add("mode");
+ listOfValid.add("bin");
+ listOfValid.add("oct");
+ listOfValid.add("dec");
+ listOfValid.add("hex");
+ listOfValid.add("rad");
+ listOfValid.add("log");
+ listOfValid.add("invlog");
+ listOfValid.add("nlog");
+ listOfValid.add("invnlog");
+ listOfValid.add("sin");
+ listOfValid.add("cos");
+ listOfValid.add("tan");
+ listOfValid.add("invsin");
+ listOfValid.add("invcos");
+ listOfValid.add("invtan");
+ listOfValid.add("!");
+ listOfValid.add("fib");
+ }
+
+ public static Boolean isValid(String op)
+ {
+ return listOfValid.contains(op);
+ }
+}
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestBasicMath.java b/src/test/java/com/zipcodewilmington/scientific_calculator/TestBasicMath.java
new file mode 100644
index 00000000..4f55abf4
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/TestBasicMath.java
@@ -0,0 +1,172 @@
+package com.zipcodewilmington.scientific_calculator;
+
+import com.zipcodewilmington.scientificcalculator.BasicMath;
+import jdk.nashorn.internal.objects.Global;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestBasicMath {
+// Addition test cases
+ @Test
+ public void TestAdditionWhole()
+ {
+ BasicMath additionTest = new BasicMath();
+ Double actual;
+ Double expected = 45.0;
+ actual = additionTest.addition(30.0,15.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestAdditionNegative()
+ {
+ BasicMath additionTest = new BasicMath();
+ Double actual;
+ Double expected = 3.0;
+ actual = additionTest.addition(8.0,-5.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestAdditionDecimal()
+ {
+ BasicMath additionTest = new BasicMath();
+ Double actual;
+ Double expected = 57.4;
+ actual = additionTest.addition(55.0,2.4);
+ assertEquals(expected, actual);
+ }
+// Subtraction test cases
+ @Test
+ public void TestSubtractionWholes()
+ {
+ BasicMath subtractionTest = new BasicMath();
+ Double actual;
+ Double expected = 15.0;
+ actual = subtractionTest.subtraction(30.0,15.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestSubtractionNegatives()
+ {
+ BasicMath subtractionTest = new BasicMath();
+ Double actual;
+ Double expected = 25.0;
+ actual = subtractionTest.subtraction(17.0,-8.0);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSubtractionDecimal()
+ {
+ BasicMath subtractionTest = new BasicMath();
+ Double actual;
+ Double expected = 5.9;
+ actual = subtractionTest.subtraction(12.4,6.5);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSubtractionGreater()
+ {
+ BasicMath subtractionTest = new BasicMath();
+ Double actual;
+ Double expected = -11.8;
+ actual = subtractionTest.subtraction(4.7,16.5);
+ assertEquals(expected, actual);
+ }
+ // Multiplication test cases
+ @Test
+ public void TestMultiplicationWholes1()
+ {
+ BasicMath multiplicationTest = new BasicMath();
+ Double actual;
+ Double expected = 15.0;
+ actual = multiplicationTest.multiplication(3.0,5.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestMultiplicationDecimals()
+ {
+ BasicMath multiplicationTest = new BasicMath();
+ Double actual;
+ Double expected = 18.48;
+ // fix this rounding error
+ actual = multiplicationTest.multiplication(8.4,2.2);
+ assertEquals(expected, actual, .0001);
+ }
+ // Division Test Cases
+ @Test
+ public void TestDivisionWholes()
+ {
+ BasicMath divisionTest = new BasicMath();
+ Double actual;
+ Double expected = 3.0;
+ actual = divisionTest.division(6.0,2.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestDivisionDecimals()
+ {
+ BasicMath divisionTest = new BasicMath();
+ Double actual;
+ Double expected = 6.2;
+ actual = divisionTest.division(12.4,2.0);
+ assertEquals(expected, actual, .0001);
+
+ }
+ @Test
+ public void TestDivisionZero() {
+ BasicMath divisionTest = new BasicMath();
+ Double actual;
+ Double expected = Global.Infinity;
+ actual = divisionTest.division(12.4, 0.0);
+ assertEquals(expected, actual, .0001);
+ }
+ @Test
+ public void TestExponentSixTwo()
+ {
+ BasicMath exponentTest = new BasicMath();
+ Double actual;
+ Double expected = 36.0;
+ actual = exponentTest.exponent(6.0,2.0);
+ assertEquals(expected, actual);
+ }
+ //Square Test Cases
+ @Test
+ public void TestsquareFour()
+ {
+ BasicMath squareTest = new BasicMath();
+ Double actual;
+ Double expected = 16.0;
+ actual = squareTest.square(4.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestSquareRootTwentyFive()
+ {
+ BasicMath squarerootTest = new BasicMath();
+ Double actual;
+ Double expected = 5.0;
+ actual = squarerootTest.squareroot(25.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestSquareRootFour()
+ {
+ BasicMath squarerootTest = new BasicMath();
+ Double actual;
+ Double expected = 2.0;
+ actual = squarerootTest.squareroot(4.0);
+ assertEquals(expected, actual);
+ }
+ @Test
+ public void TestSquareRootNegative()
+ {
+ BasicMath squarerootTest = new BasicMath();
+ Double actual;
+ Double expected = Double.NaN;
+ actual = squarerootTest.squareroot(-4.0);
+ assertEquals(expected, actual);
+ }
+}
+
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestConversionMath.java b/src/test/java/com/zipcodewilmington/scientific_calculator/TestConversionMath.java
new file mode 100644
index 00000000..e843dc0f
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/TestConversionMath.java
@@ -0,0 +1,95 @@
+package com.zipcodewilmington.scientific_calculator;
+
+import com.zipcodewilmington.scientificcalculator.BasicMath;
+import com.zipcodewilmington.scientificcalculator.ConversionMath;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestConversionMath {
+ @Test
+ public void TestFeetToMetersWhole() {
+ ConversionMath feetToMetersTest = new ConversionMath();
+ Double actual;
+ Double expected = 0.30478512648582745;
+ actual = feetToMetersTest.feetToMeters(1.0);
+ assertEquals(expected, actual, 0.001);
+ }
+ @Test
+ public void TestFeetToMetersDecimal() {
+ ConversionMath feetToMetersTest = new ConversionMath();
+ Double actual;
+ Double expected = 0.762;
+ actual = feetToMetersTest.feetToMeters(2.5);
+ assertEquals(expected, actual, 0.001);
+ }
+
+ @Test
+ public void TestCtoF() {
+ ConversionMath celsiusToFahrenheitTest = new ConversionMath();
+ Double actual;
+ Double expected = 140.0;
+ actual = celsiusToFahrenheitTest.celsiusToFahrenheit(60.0);
+ assertEquals(expected, actual, 0.001);
+ }
+ @Test
+ public void TestCtoFDecimal() {
+ ConversionMath celsiusToFahrenheitTest = new ConversionMath();
+ Double actual;
+ Double expected = 107.6;
+ actual = celsiusToFahrenheitTest.celsiusToFahrenheit(42.0);
+ assertEquals(expected, actual, 0.001);
+ }
+
+ @Test
+ public void TestFtoC() {
+ ConversionMath fahrenheitToCelsiusTest = new ConversionMath();
+ Double actual;
+ Double expected = 60.0;
+ actual = fahrenheitToCelsiusTest.fahrenheitToCelsius(140.0);
+ assertEquals(expected, actual, 0.001);
+ }
+
+ @Test
+ public void TestFtoCDecimal() {
+ ConversionMath fahrenheitToCelsiusTest = new ConversionMath();
+ Double actual;
+ Double expected = 37.778;
+ actual = fahrenheitToCelsiusTest.fahrenheitToCelsius(100.0);
+ assertEquals(expected, actual, 0.001);
+ }
+
+ @Test
+ public void TestPoundstoKilos() {
+ ConversionMath poundsToKilosTest = new ConversionMath();
+ Double actual;
+ Double expected = 5.44311;
+ actual = poundsToKilosTest.poundsToKilos(12.0);
+ assertEquals(expected, actual, 0.001);
+ }
+
+ @Test
+ public void TestPoundstoKilosDecimal() {
+ ConversionMath poundsToKilosTest = new ConversionMath();
+ Double actual;
+ Double expected = 7.9365;
+ actual = poundsToKilosTest.poundsToKilos(17.5);
+ assertEquals(expected, actual, 0.001);
+ }
+ @Test
+ public void TestKilosToPounds() {
+ ConversionMath kilosToPoundsTest= new ConversionMath();
+ Double actual;
+ Double expected = 81.585;
+ actual = kilosToPoundsTest.kilosToPounds(37.0);
+ assertEquals(expected, actual, 0.001);
+ }
+ @Test
+ public void TestKilosToPoundsDecimal() {
+ ConversionMath kilosToPoundsTest= new ConversionMath();
+ Double actual;
+ Double expected = 26.901;
+ actual = kilosToPoundsTest.kilosToPounds(12.2);
+ assertEquals(expected, actual, 0.001);
+ }
+}
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMemory.java b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMemory.java
new file mode 100644
index 00000000..4df437b0
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMemory.java
@@ -0,0 +1,98 @@
+package com.zipcodewilmington.scientific_calculator;
+
+import com.zipcodewilmington.scientificcalculator.Memory;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class TestMemory {
+ @Test
+ public void TestSetMemoryToOneHundred()
+ {
+ Double expected = 100.00;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(100.00);
+ Double actual = TestMemory.getMemory();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetMemoryToNegativeFive()
+ {
+ Double expected = -5.0;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(-5.0);
+ Double actual = TestMemory.getMemory();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetMemoryToPointOne()
+ {
+ Double expected = 0.1;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(0.1);
+ Double actual = TestMemory.getMemory();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestResetMemory()
+ {
+ Double expected = 0.0;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(-5.0);
+ TestMemory.resetMemory();
+ Double actual = TestMemory.getMemory();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestMemoryNaN()
+ {
+ Double expected = Double.NaN;
+ Memory TestMemory = new Memory();
+ Double actual = TestMemory.getMemory();
+
+ assertNotEquals(expected, actual);
+ }
+
+ @Test
+ public void TestResetMemoryNaN()
+ {
+ Double expected = Double.NaN;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(7.0);
+ TestMemory.resetMemory();
+ Double actual = TestMemory.getMemory();
+
+ assertNotEquals(expected, actual);
+ }
+
+ @Test
+ public void TestMemoryNull()
+ {
+ Double expected = null;
+ Memory TestMemory = new Memory();
+ Double actual = TestMemory.getMemory();
+
+ assertNotEquals(expected, actual);
+ }
+
+ @Test
+ public void TestResetMemoryNull()
+ {
+ Double expected = null;
+ Memory TestMemory = new Memory();
+ TestMemory.setMemory(1979.0000);
+ TestMemory.resetMemory();
+ Double actual = TestMemory.getMemory();
+
+ assertNotEquals(expected, actual);
+ }
+}
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/BoxMakerTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/BoxMakerTest.java
new file mode 100644
index 00000000..3815e92e
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/BoxMakerTest.java
@@ -0,0 +1,119 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class BoxMakerTest {
+
+ @Test
+ public void TestGetWidthGeneric()
+ {
+ int expected = 30;
+ BoxMaker TestBoxMaker = new BoxMaker();
+ int actual = TestBoxMaker.getWidth();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestGetWidthSizeTwelve()
+ {
+ int expected = 12;
+ BoxMaker TestBoxMaker = new BoxMaker(12);
+ int actual = TestBoxMaker.getWidth();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetWidth()
+ {
+ int expected = 55;
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(55);
+ int actual = TestBoxMaker.getWidth();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetWidthTooSmall()
+ {
+ int expected = 30;
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(-9);
+ int actual = TestBoxMaker.getWidth();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetWidthTooBig()
+ {
+ int expected = 30;
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(4000);
+ int actual = TestBoxMaker.getWidth();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestDraw()
+ {
+ String expected =
+ "╔════════╗\n" +
+ "║ hello║\n" +
+ "╚════════╝\n";
+
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(10);
+ String actual = TestBoxMaker.draw("Hello");
+ }
+
+ @Test
+ public void TestDrawTwoLines()
+ {
+ String expected =
+ "╔═════╗\n" +
+ "║hello║\n" +
+ "║James║\n" +
+ "╚═════╝\n";
+
+
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(7);
+ String actual = TestBoxMaker.draw("Hello", "James");
+ }
+
+ @Test
+ public void TestDrawTooLong()
+ {
+ String expected =
+ "╔═════╗\n" +
+ "║hello║\n" +
+ "║ ║\n" +
+ "╚═════╝\n";
+
+
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(7);
+ String actual = TestBoxMaker.draw("Hello James");
+ }
+
+ @Test
+ public void TestDrawNothing()
+ {
+ String expected =
+ "╔═════╗\n" +
+ "║ ║\n" +
+ "║ ║\n" +
+ "╚═════╝\n";
+
+
+ BoxMaker TestBoxMaker = new BoxMaker();
+ TestBoxMaker.setWidth(7);
+ String actual = TestBoxMaker.draw("");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/DisplayTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/DisplayTest.java
new file mode 100644
index 00000000..39712e0d
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/DisplayTest.java
@@ -0,0 +1,303 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DisplayTest {
+/* Goal format:
+╔════════════════════════════════════════════════╗
+║ ║
+║ 10100 ║
+║ BIN ║
+╚════════════════════════════════════════════════╝
+
+ */
+
+ @Test
+ public void TestUpdateInitValue()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 0 ║\n" +
+ "║ ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestUpdateBinaryEight()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 1000 ║\n" +
+ "║ BIN ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(8.0);
+ TestDisplay.setMode(Display.Modes.BINARY);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestUpdateBinaryTwentyPointFive()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 10100 ║\n" +
+ "║ BIN ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(20.5);
+ TestDisplay.setMode(Display.Modes.BINARY);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestClear() {
+ Double expected = 0.0;
+ Display TestDisplay = new Display();
+ Double actual;
+ TestDisplay.setDisplay(99.99999);
+ TestDisplay.clear();
+ actual = TestDisplay.getDisplay();
+
+ assertEquals(expected, actual);
+ }
+
+/* @Test
+ public void TestInvSign() {
+ Double expected = -47.6;
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(47.6);
+ Double actual = TestDisplay.invSign();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInvSignAgain() {
+ Double expected = 105.9;
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(-105.9);
+ Double actual = TestDisplay.invSign();
+
+ assertEquals(expected, actual);
+ } */
+
+ @Test
+ public void TestAbsoluteValueOfTen()
+ {
+ Double expected = 10.0;
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(10.0);
+ Double actual = TestDisplay.absoluteValue();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestAbsoluteValueOfNegFourtyFive()
+ {
+ Double expected = 45.0;
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(-45.0);
+ Double actual = TestDisplay.absoluteValue();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestAbsoluteValueOfZero()
+ {
+ Double expected = 0.0;
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(0.0);
+ Double actual = TestDisplay.absoluteValue();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetModeOCT()
+ {
+ Display.Modes expected = Display.Modes.OCTAL;
+ Display TestDisplay = new Display();
+ TestDisplay.setMode(Display.Modes.OCTAL);
+ Display.Modes actual = TestDisplay.getMode();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetModeBINARY()
+ {
+ Display.Modes expected = Display.Modes.BINARY;
+ Display TestDisplay = new Display();
+ TestDisplay.setMode(Display.Modes.BINARY);
+ Display.Modes actual = TestDisplay.getMode();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetModeDEC()
+ {
+ Display.Modes expected = Display.Modes.DEC;
+ Display TestDisplay = new Display();
+ TestDisplay.setMode(Display.Modes.DEC);
+ Display.Modes actual = TestDisplay.getMode();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestSetModeCycleFiveTimes()
+ {
+ Display.Modes expected = Display.Modes.BINARY;
+ Display TestDisplay = new Display();
+ TestDisplay.setMode();
+ TestDisplay.setMode();
+ TestDisplay.setMode();
+ TestDisplay.setMode();
+ TestDisplay.setMode();
+ Display.Modes actual = TestDisplay.getMode();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestToggleRadians()
+ {
+ Boolean expected = true;
+ Display TestDisplay = new Display();
+ TestDisplay.toggleRadians();
+ Boolean actual = TestDisplay.getIsRadians();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestToggleRadiansFourHundredTimes()
+ {
+ Boolean expected = false;
+ Display TestDisplay = new Display();
+ for(int i = 0; i < 400; i++)
+ {
+ TestDisplay.toggleRadians();
+ }
+ Boolean actual = TestDisplay.getIsRadians();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestDisplayRadians()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ RAD ║\n" +
+ "║ 90 ║\n" +
+ "║ ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(90.0);
+ TestDisplay.toggleRadians();
+ String actual = TestDisplay.update();
+ }
+
+ @Test
+ public void TestNaNDisplaysError ()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ERR ║\n" +
+ "║ ERR ║\n" +
+ "║ ERR ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(6.0/0.0);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestClearVoidsError()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 0 ║\n" +
+ "║ ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(6.0/0.0);
+ TestDisplay.clear();
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestMaxDisplaySize()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 100000000000000000000000000000000000000000000 ║\n" +
+ "║ BIN ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(140737488355328.0);
+ TestDisplay.setMode(Display.Modes.BINARY);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestMaxDisplaySizeTwo()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 9.9999999999999999999999999999999999999999999 ║\n" +
+ "║ ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(9.9999999999999999999999999999999999999999999);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TextDisplayPi()
+ {
+ String expected =
+ "╔════════════════════════════════════════════════╗\n" +
+ "║ ║\n" +
+ "║ 3.141592653589793 ║\n" +
+ "║ ║\n" +
+ "╚════════════════════════════════════════════════╝\n";
+
+ Display TestDisplay = new Display();
+ TestDisplay.setDisplay(Math.PI);
+ String actual = TestDisplay.update();
+
+ assertEquals(expected, actual);
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/InputErrorHandlerTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/InputErrorHandlerTest.java
new file mode 100644
index 00000000..1faa9815
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/InputErrorHandlerTest.java
@@ -0,0 +1,98 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import jdk.internal.util.xml.impl.Input;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class InputErrorHandlerTest {
+ @Test
+ public void TestInputErrorHandlerNumber()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validNumber("500.505");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerSecondNumber()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validNumber("500");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerAdd()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("+");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerWrongAdd()
+ {
+ Boolean expected = false;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("add");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerSub()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("-");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerMode()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("mode");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerSqrt()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("sqrt");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerFoo()
+ {
+ Boolean expected = false;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("foo");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestInputErrorHandlerClear()
+ {
+ Boolean expected = true;
+ InputErrorHandler TestInputErrorHandler = new InputErrorHandler();
+ Boolean actual = TestInputErrorHandler.validOp("c");
+
+ assertEquals(expected, actual);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/MenuTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/MenuTest.java
new file mode 100644
index 00000000..4e471893
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/MenuTest.java
@@ -0,0 +1,9 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MenuTest {
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/OperationTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/OperationTest.java
new file mode 100644
index 00000000..94fb6536
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/OperationTest.java
@@ -0,0 +1,68 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class OperationTest {
+
+ @Test
+ public void TestisSetting()
+ {
+ Boolean expected = true;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isSetting("c");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestisSettingAdd()
+ {
+ Boolean expected = false;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isSetting("+");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestisSettingBar()
+ {
+ Boolean expected = false;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isSetting("bar");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestisSettingMPlus()
+ {
+ Boolean expected = true;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isSetting("m+");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestisisUnary()
+ {
+ Boolean expected = true;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isUnary("nlog");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestisBinary()
+ {
+ Boolean expected = true;
+ Operation TestOperation = new Operation();
+ Boolean actual = TestOperation.isUnary("*");
+
+ assertEquals(expected, actual);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/PromptTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/PromptTest.java
new file mode 100644
index 00000000..5bd59755
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/PromptTest.java
@@ -0,0 +1,7 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import static org.junit.Assert.*;
+
+public class PromptTest {
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/TestLogarithm.java b/src/test/java/com/zipcodewilmington/scientificcalculator/TestLogarithm.java
new file mode 100644
index 00000000..1c435067
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/TestLogarithm.java
@@ -0,0 +1,203 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestLogarithm {
+
+ ////********* ***********////////////////////
+
+ @Test
+ public void logNegative() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.Log(-1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void logZero() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.Log(0.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void logOne() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.Log(1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void logDecimal() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.17609125905568124;
+ actual= Logarithm.Log(1.5);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void logThousand() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 3.0;
+ actual= Logarithm.Log(1000.0);
+ assertEquals(expected,actual);
+
+ }
+
+
+ ////********* ***********////////////////////
+
+ @Test
+ public void invLogNegative() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.001;
+ actual= Logarithm.InvLog(-3.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void invLogZero() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 1.0;
+ actual= Logarithm.InvLog(0.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void invLogThree() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 1000.0;
+ actual= Logarithm.InvLog(3.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void invLogDecimal() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 1584.893192461114;
+ actual= Logarithm.InvLog(3.2);
+ assertEquals(expected,actual);
+
+ }
+
+ ////********* ***********////////////////////
+
+ @Test
+ public void NLogNegative() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.NLog(-1.0);
+ assertEquals(expected,actual);
+ }
+ @Test
+ public void NLogZero() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.NLog(0.0);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void NLogOne() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.0;
+ actual= Logarithm.NLog(1.0);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void NLogDecimal() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 1.1314021114911006;
+ actual= Logarithm.NLog(3.1);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void invNLogNegative() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.36787944117144233;
+ actual= Logarithm.InvNLog(-1.0);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void invNLogZero() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 1.0;
+ actual= Logarithm.InvNLog(0.0);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void invNLogOne() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 2.718281828459045;
+ actual= Logarithm.InvNLog(1.0);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void invNLogDecimal() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 0.33287108369807955;
+ actual= Logarithm.InvNLog(-1.1);
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void invNLogFour() {
+
+ Logarithm TestLogarithm = new Logarithm();
+ Double actual;
+ Double expected = 54.59815003314423;
+ actual= Logarithm.InvNLog((double)4);
+ assertEquals(expected,actual);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java b/src/test/java/com/zipcodewilmington/scientificcalculator/TestMainApplication.java
similarity index 58%
rename from src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
rename to src/test/java/com/zipcodewilmington/scientificcalculator/TestMainApplication.java
index 94e8d987..e8ccb8dd 100644
--- a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/TestMainApplication.java
@@ -1,4 +1,4 @@
-package com.zipcodewilmington.scientific_calculator;
+package com.zipcodewilmington.scientificcalculator;
/**
* Created by leon on 2/9/18.
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/TestOtherFunctions.java b/src/test/java/com/zipcodewilmington/scientificcalculator/TestOtherFunctions.java
new file mode 100644
index 00000000..b41efe5d
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/TestOtherFunctions.java
@@ -0,0 +1,121 @@
+package com.zipcodewilmington.scientificcalculator;
+
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestOtherFunctions {
+
+ @Test
+ public void FactNegativeOne() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=0.0;
+ actual= OtherFunctions.Fact(-1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FactZero() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected= 1.0;
+ actual = OtherFunctions.Fact(1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FactOne() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=1.0;
+ actual= OtherFunctions.Fact(1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FactFive() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=120.0;
+ actual= OtherFunctions.Fact(5.0);
+ assertEquals(expected,actual);
+
+ }
+
+ ///////******************* **************************////////////////
+
+ @Test
+ public void FibonNegativeOne() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected = 0.0;
+ actual = OtherFunctions.Fibon(-1.0);
+ assertEquals(expected, actual);
+
+ }
+
+ @Test
+ public void FibonZero() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=0.0;
+ actual= OtherFunctions.Fibon(0.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FibonOne() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=1.0;
+ actual= OtherFunctions.Fibon(1.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FibonTwo() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=1.0;
+ actual= OtherFunctions.Fibon(2.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FibonThree() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=2.0;
+ actual= OtherFunctions.Fibon(3.0);
+ assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void FibonTen() {
+
+ OtherFunctions OtherFunctionsTest = new OtherFunctions();
+ Double actual;
+ Double expected=55.0;
+ actual= OtherFunctions.Fibon(10.0);
+ assertEquals(expected,actual);
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/TestTrig.java b/src/test/java/com/zipcodewilmington/scientificcalculator/TestTrig.java
new file mode 100644
index 00000000..ad45e5ba
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/TestTrig.java
@@ -0,0 +1,132 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestTrig {
+
+ @Test
+ public void sinPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=1.0;
+ actual= Trig.Sin((double)450, "DEG");
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void sinNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=0.6832837250355236;
+ actual= Trig.Sin((double)-450, "RAD");
+ assertEquals(expected,actual);
+ }
+
+
+ @Test
+ public void cosPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=0.8746197071393957;
+ actual= Trig.Cos((double)389, "DEG");
+ assertEquals(expected,actual);
+ }
+
+ @Test
+ public void cosNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=0.8485862232545117;
+ actual= Trig.Cos((double)-389, "RAD");
+ assertEquals(expected,actual, 0.001);
+ }
+
+ @Test
+ public void tanPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=1.633123935319537E16;
+ actual= Trig.Tan((double)450, "DEG");
+ assertEquals(expected,actual, 1.0001);
+ }
+
+ @Test
+ public void tanNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=-0.9358090133927123;
+ actual=(Trig.Tan((double)-450, "RAD"));
+ assertEquals(expected,actual, 1.001);
+ }
+
+ @Test
+ public void invSinNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=-60.0;
+ actual= Trig.InvSin(-0.8660254);
+ assertEquals(expected,actual, .0001);
+ }
+
+ @Test
+ public void invSinPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=45.0;
+ actual= Trig.InvSin(0.7071068);
+ assertEquals(expected,actual, .0001);
+ }
+
+ @Test
+ public void invCosPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=45.0;
+ actual= Trig.InvCos(0.7071068);
+ assertEquals(expected,actual, .0001);
+
+ }
+
+ @Test
+ public void invCosNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=150.0;
+ actual= Trig.InvCos(-0.8660254);
+ assertEquals(expected,actual, 1.0001);
+
+ }
+
+ @Test
+ public void invTanPositive(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=60.0;
+ actual= Trig.InvTan(1.732050808);
+ assertEquals(expected,actual, 1.0001);
+ }
+
+ @Test
+ public void invTanNegative(){
+
+ Trig TestTrig=new Trig();
+ Double actual;
+ Double expected=-30.0;
+ actual= Trig.InvTan(-0.577350269);
+ assertEquals(expected,actual, 1.0001);
+ }
+ }
+
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/ValidOperationsTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/ValidOperationsTest.java
new file mode 100644
index 00000000..de9d9c88
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/ValidOperationsTest.java
@@ -0,0 +1,55 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class ValidOperationsTest {
+ @Test
+ public void TestValidOperationsAdd()
+ {
+ Boolean expected = true;
+ ValidOperations TestValidOperations = new ValidOperations();
+ Boolean actual = TestValidOperations.isValid("+");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestValidOperationsSub()
+ {
+ Boolean expected = true;
+ ValidOperations TestValidOperations = new ValidOperations();
+ Boolean actual = TestValidOperations.isValid("-");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestValidOperationsWrongAdd()
+ {
+ Boolean expected = false;
+ ValidOperations TestValidOperations = new ValidOperations();
+ Boolean actual = TestValidOperations.isValid("add");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestValidOperationsFoo()
+ {
+ Boolean expected = false;
+ ValidOperations TestValidOperations = new ValidOperations();
+ Boolean actual = TestValidOperations.isValid("foo");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void TestClear()
+ {
+ Boolean expected = true;
+ ValidOperations TestValidOperations = new ValidOperations();
+ Boolean actual = TestValidOperations.isValid("c");
+ }
+}
\ No newline at end of file