diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..9a874b57
Binary files /dev/null and b/.DS_Store differ
diff --git a/.gitignore b/.gitignore
index de469bb3..5557063f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -149,6 +149,7 @@ fabric.properties
.project
.classpath
.settings
+.DS_Store
#maven build target
diff --git a/pom.xml b/pom.xml
index e7cb4f6b..d8cd763e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,14 @@
com.zipcodewilmington
scientific_calculator
1.0-SNAPSHOT
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
\ No newline at end of file
diff --git a/src/.DS_Store b/src/.DS_Store
new file mode 100644
index 00000000..9604c915
Binary files /dev/null and b/src/.DS_Store differ
diff --git a/src/main/.DS_Store b/src/main/.DS_Store
new file mode 100644
index 00000000..55c1fcbe
Binary files /dev/null and b/src/main/.DS_Store differ
diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store
new file mode 100644
index 00000000..35a54bf0
Binary files /dev/null and b/src/main/java/.DS_Store differ
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java
new file mode 100644
index 00000000..8337c259
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java
@@ -0,0 +1,70 @@
+package com.zipcodewilmington.scientificcalculator;
+import java.util.Scanner;
+
+public class Calculator {
+
+ public Double operator;
+ public Double firstOption;
+ public Double secondOption;
+ public Double ans;
+ public Double history;
+ public Double calcChoice;
+
+ public Calculator() {
+
+ }
+
+ public Double setCalcChoice(Double choice) {
+ this.calcChoice = choice;
+ return choice;
+ }
+
+ public Double getCalcChoice() {
+ return this.calcChoice;
+ }
+
+
+ public Double setAns(Double ans) {
+ this.ans = ans;
+ return ans;
+ }
+
+ public Double getAns() {
+ return this.ans;
+ }
+
+ public Double getCurrentValue(Double currentValue) {
+ return this.history;
+ }
+
+ public Double getInputFromUser() {
+ Scanner scanner = new Scanner(System.in);
+ Double userInput = scanner.nextDouble();
+ return userInput;
+ }
+
+ public void setFirstInput(Double input){
+ firstOption = input;
+ }
+
+ public void setSecondOptionInput(Double input){
+ secondOption = input;
+ }
+
+ public void setOperator(Double input){
+ operator = input;
+ }
+
+ public Double chooseCalc() {
+ return null;
+ }
+
+ public Double getFirstNumber() {
+ return firstOption;
+ }
+
+ public Double getSecondNumber() {
+ return secondOption;
+ }
+
+}
\ 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..f450428f 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
@@ -22,11 +22,11 @@ public static String getStringInput(String prompt) {
return userInput;
}
- public static Integer getIntegerInput(String prompt) {
+ /*public static Integer getIntegerInput(String prompt) {
return null;
}
public static Double getDoubleInput(String prompt) {
return null;
- }
-}
+ }*/
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/CoreFunctions.java b/src/main/java/com/zipcodewilmington/scientificcalculator/CoreFunctions.java
new file mode 100644
index 00000000..09a5f076
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/CoreFunctions.java
@@ -0,0 +1,61 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.lang.*;
+import com.sun.tools.javac.util.StringUtils;
+
+public class CoreFunctions {
+
+ Double display;
+
+ //This is a constructor for CLass
+ public CoreFunctions() {
+
+ }
+
+ /*public double displayScreen() {
+ display = 0.0;
+ return display;
+ }*/
+
+ public boolean IsANumber(Double input) {
+ return true;
+ }
+
+ /*public class convertToDouble {
+ private String number1;
+ double convertedNumber = Double.parseDouble(number1);
+ }*/
+ public Double Add(Double a, Double b) {
+ Double sum = a + b;
+ return sum;
+ }
+
+ public Double Subtract(Double a, Double b) {
+ Double sum = a - b;
+ return sum;
+ }
+
+ public Double Multiply(Double a, Double b) {
+ Double sum = a * b;
+ return sum;
+ }
+
+ public Double Divide(Double a, Double b) {
+ Double sum = a / b;
+ return sum;
+ }
+
+ public Double SquareRoot(Double a) {
+ Double sum = Math.sqrt(a);
+ return sum;
+ }
+
+ public Double Square(Double a, Double b) {
+ Double sum = a - b;
+ return sum;
+ }
+
+ public Double Inverse() {
+ return null;
+ }
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
index 5f421325..c716570c 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
@@ -1,17 +1,454 @@
package com.zipcodewilmington.scientificcalculator;
+import java.util.Scanner;
+
+import sun.util.calendar.CalendarUtils;
-/**
- * Created by leon on 2/9/18.
- */
public class MainApplication {
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("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);
+ Double currentValue = 0.0;
+ boolean t = true;
+ while (t) {
+
+ Calculator calc = new Calculator();
+ User user = new User(0.);
+ ScientificFunctions func = new ScientificFunctions();
+ // The lines below this were posibbly going to be used for getting the current value. I am still working on
+ // the idea as a whole.
+ //Double currentValue = calc.getAns();
+ //System.out.println("Current Value: " + currentValue);
+
+
+ int y = 2;
+ do {
+ try {
+ System.out.println("Please choose either '1' for 'Basic' or '2' for 'Scientific' calculator");
+ Double choice = calc.getInputFromUser();
+
+ if (choice.equals(1.)) {
+ System.out.println("Please choose an option from the below Menu by selecting " +
+ "it's corresponding number;\n" +
+ "1) Addition\n" +
+ "2) Subtraction\n" +
+ "3) Multiplication\n" +
+ "4) Divide \n");
+
+
+ y = 1;
+ } else if (choice.equals(2.)) {
+ System.out.println("Please choose an option from the below Menu;\n" +
+ "1) Addition\n" +
+ "2) Subtraction\n" +
+ "3) Multiplication\n" +
+ "4) Divide \n" +
+ "5) degree\n" +
+ "6) natural log\n" +
+ "7) base log\n" +
+ "8) inverse log\n" +
+ "9) square root\n" +
+ "10) inverse\n" +
+ "11) square\n" +
+ "12) exponent\n" +
+ "13) change sign\n" +
+ "14) sine\n" +
+ "15) cos\n" +
+ "16) tan\n" +
+ "17) inverseCosine\n" +
+ "18) inverseTangent\n" +
+ "19) inverseSine\n" +
+ "20) radian\n" +
+ "21) factorial\n" +
+ "22) fibonacci\n");
+
+ y = 1;
+ } else {
+ System.out.println("Invalid input");
+ }
+ } catch (Exception e) {
+ System.out.println("Sorry bad input");
+ }
+ } while (y == 2);
+
+/*We need to also error handle the options to pick the menus. We decided that these would not be done now and we
+ would save that for the absolute last issue. */
+ int test = 2;
+ do {
+ try {
+ Double operator = calc.getInputFromUser();
+ calc.setCalcChoice(operator);
+
+ if (operator.equals(1.)) {
+ int x = 2;
+
+ do {
+ try {
+
+ System.out.println("Enter your first number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ String storedFirstNum = calc.getFirstNumber().toString();
+
+ System.out.println("Enter your Second Number");
+ Double secondNum = calc.getInputFromUser();
+ calc.setSecondOptionInput(secondNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.add(calc.getFirstNumber(), calc.getSecondNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(2.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your first number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ System.out.println("Enter your Second Number");
+ Double secondNum = calc.getInputFromUser();
+ calc.setSecondOptionInput(secondNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.subtract(calc.getFirstNumber(), calc.getSecondNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(3.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your first number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ System.out.println("Enter your Second Number");
+ Double secondNum = calc.getInputFromUser();
+ calc.setSecondOptionInput(secondNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.multiply(calc.getFirstNumber(), calc.getSecondNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(4.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your first number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ System.out.println("Enter your Second Number");
+ Double secondNum = calc.getInputFromUser();
+ if (secondNum.equals(0.)) {
+ System.out.println("Err");
+ } else {
+ calc.setSecondOptionInput(secondNum);
+ x = 1;
+ }
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.divide(calc.getFirstNumber(), calc.getSecondNumber());
+ calc.setAns(ans);
+
+//--------------------------Basic---------------------------------------------
+
+ }
+ if (operator.equals(5.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.degree(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(6.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.naturalLog(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(7.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.baseLog(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(8.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.inverseLog(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(9.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.squareRoot(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(10.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.inverse(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(11.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.square(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(12.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.exponent(calc.getFirstNumber(), calc.getSecondNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(13.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.changeSign(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(14.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.sine(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(15.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.cosine(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(16.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.tangent(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(17.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.inverseCosine(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(18.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.inverseTangent(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(19.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.inverseSine(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(20.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.radian(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(21.)) {
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+ Double ans = ScientificFunctions.factorial(calc.getFirstNumber());
+ calc.setAns(ans);
+ } else if (operator.equals(22.)) {
+
+ int x = 2;
+ do {
+ try {
+ System.out.println("Enter your number");
+ Double firstNum = calc.getInputFromUser();
+ calc.setFirstInput(firstNum);
+ x = 1;
+
+ System.out.println(ScientificFunctions.fibonacci(calc.getFirstNumber()));
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input");
+ }
+ } while (x == 2);
+
+
+
+ } else {
+ //System.out.println("Error");
+ }
+ test++;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input. Please enter a valid choice(number): ");
+ }
+ } while (test == 2);
+
+ if (calc.getCalcChoice() <= 21.) {
+ System.out.println("Your answer is " + calc.getAns() + "");
+
+ System.out.println("If you wish to convert your number to hexadecimal(1), Octal(2), or Binary(3), " +
+ "please enter the corresponding number. You may also press 0 to reset the calculator.");
+ }
+ int q = 2;
+ do {
+ try {
+ Double temp = calc.getInputFromUser();
+ if (temp.equals(1.)) {
+ System.out.println("Your Hexadecimal answer for " + calc.getAns() + " is "
+ + ScientificFunctions.Hexadecimal(calc.getAns().intValue()));
+ }
+ else if (temp.equals(2.)) {
+ System.out.println("Your Octal answer for " + calc.getAns() + " is "
+ + ScientificFunctions.Octal(calc.getAns().intValue()));
+ }
+ else if (temp.equals(3.)) {
+ System.out.println("Your Binary answer for " + calc.getAns() + " is "
+ + ScientificFunctions.Binary(calc.getAns().intValue()));
+ } else if (temp.equals(0.)){
+ Runtime.getRuntime().exec("clear");
+ } q++;
+ } catch (Exception e) {
+ System.out.println("Sorry, bad input. Please enter a valid choice(number): ");
+ }
+ } while (q == 2);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.class b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.class
new file mode 100644
index 00000000..3b2018cf
Binary files /dev/null and b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.class differ
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.java
new file mode 100644
index 00000000..9efbe484
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFunctions.java
@@ -0,0 +1,177 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class ScientificFunctions {
+
+ public ScientificFunctions(){
+
+ }
+
+ public boolean isaNumber(Double input) {
+ return true;
+ }
+
+ /*public class convertToDouble {
+ private String number1;
+ double convertedNumber = Double.parseDouble(number1);
+ }*/
+ public static Double add(Double a, Double b) {
+ Double sum = a + b;
+ return sum;
+ }
+
+ public static Double subtract(Double a, Double b) {
+ Double sum = a - b;
+ return sum;
+ }
+
+ public static Double multiply(Double a, Double b) {
+ Double sum = a * b;
+ return sum;
+ }
+
+ public static Double divide(Double a, Double b){
+ if (b == 0){
+ // tell user division by 0 is not allowed and to re enter input
+ }
+ else {
+ Double sum = a / b;
+ return sum;
+ }
+ return null;
+ }
+
+ public static Double squareRoot(Double a) {
+ Double sum = Math.sqrt(a);
+ return sum;
+ }
+
+ public static Double square(Double a) {
+ Double sum = a*a;
+ return sum;
+ }
+ // Add all inverses? Multiplicative/additive/
+ public static Double inverse(Double a) {
+ Double sum = (1/a);
+ return sum;
+ }
+ // reset memory to 0?
+ public void Clear() {
+
+ }
+
+ public static Double exponent(Double a, Double e){
+ Double sum = Math.pow(a, e);
+ return sum;
+ }
+
+ public static Double changeSign(Double a){
+ if(a < 0){
+ Double value = Math.abs(a);
+ return value;
+ }
+ else{
+ Double value = a - (a*2);
+ return value;
+ }
+ }
+
+ // returns sine
+ public static Double sine(Double input){
+ Double number = input;
+ return Math.sin(number);
+ }
+ // returns cosine
+ public static Double cosine(Double input){
+ Double number = input;
+ return Math.cos(number);
+ }
+ // returns tangent
+ public static Double tangent(Double input){
+ Double number = input;
+ return Math.tan(number);
+ }
+ // inverse sine
+ public static Double inverseSine(Double input){
+ Double number = input;
+ return Math.asin(number);
+ }
+ // inverse cosine
+ public static Double inverseCosine(Double input){
+ Double number = input;
+ return Math.acos(number);
+ }
+ // inverse tangent
+ public static Double inverseTangent(Double input){
+ Double number = input;
+ return Math.atan(number);
+ }
+
+ // to radians
+
+ public static Double radian(Double input){
+ Double number = input;
+ return Math.toRadians(number);
+ }
+
+ // to degrees
+ public static Double degree(Double input){
+ Double number = input;
+ return Math.toDegrees(number);
+ }
+
+ // calc natural log
+ public static Double naturalLog(Double input){
+ Double number = input;
+ return Math.log(number);
+ }
+
+ // calc base log
+ public static Double baseLog(Double input){
+ Double number = input;
+ return Math.log10(number);
+ }
+ // calc inverse log
+ public static Double inverseLog(Double input){
+ Double number = Math.pow(10, input);
+ return number;
+ }
+
+ // calc inverse natural log
+ public Double inverseNaturalLog(Double input){
+ Double number = Math.pow(Math.E, input);
+ return number;
+ }
+
+ // calculate factorial
+ public static Double factorial(Double input){
+ Double number = 1.;
+ for(int i = 2; i <= input; i++){
+ number = number * i;
+ }
+ return number;
+
+}
+ public static String fibonacci(Double input){
+ Double maxNumber = input;
+ Integer previousNumber = 0;
+ Integer nextNumber = 1;
+ String str = "";
+ for (int i = 1; i <= maxNumber; i++){
+ str += " " + previousNumber;
+ int sum = previousNumber + nextNumber;
+ previousNumber = nextNumber;
+ nextNumber = sum;
+ }
+ return str;
+ }
+
+ public static String Hexadecimal(Integer input) {
+ return Integer.toHexString(input);
+ }
+ public static String Octal(Integer input) {
+ return Integer.toOctalString(input);
+ }
+ public static String Binary(Integer input) {
+ return Integer.toBinaryString(input);
+ }
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/User.java b/src/main/java/com/zipcodewilmington/scientificcalculator/User.java
new file mode 100644
index 00000000..a7db4808
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/User.java
@@ -0,0 +1,19 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.util.Scanner;
+
+public class User {
+
+ Double usersOperator;
+
+ public User (Double usersOperator) {
+ this.usersOperator = usersOperator;
+ }
+
+ public Double getInputFromUser() {
+ Scanner scanner = new Scanner(System.in);
+ Double userInput = scanner.nextDouble();
+ return userInput;
+ }
+}
+
diff --git a/src/test/.DS_Store b/src/test/.DS_Store
new file mode 100644
index 00000000..55c1fcbe
Binary files /dev/null and b/src/test/.DS_Store differ
diff --git a/src/test/java/.DS_Store b/src/test/java/.DS_Store
new file mode 100644
index 00000000..35a54bf0
Binary files /dev/null and b/src/test/java/.DS_Store differ
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/CoreFunctionsTest.java b/src/test/java/com/zipcodewilmington/scientific_calculator/CoreFunctionsTest.java
new file mode 100644
index 00000000..702de911
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/CoreFunctionsTest.java
@@ -0,0 +1,12 @@
+package com.zipcodewilmington.scientific_calculator;
+
+import com.zipcodewilmington.scientificcalculator.CoreFunctions;
+import com.zipcodewilmington.scientificcalculator.ScientificFunctions;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class CoreFunctionsTest {
+
+}
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificFunctionsTest.java b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificFunctionsTest.java
new file mode 100644
index 00000000..888fa2ba
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/ScientificFunctionsTest.java
@@ -0,0 +1,263 @@
+package com.zipcodewilmington.scientific_calculator;
+
+import com.zipcodewilmington.scientificcalculator.ScientificFunctions;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ScientificFunctionsTest {
+ com.zipcodewilmington.scientificcalculator.ScientificFunctions ScientificFunctions = new ScientificFunctions();
+
+ @Test
+ public void positiveintegerAdderTest() {
+ Double assumed = 2.;
+ Double actual = ScientificFunctions.add(1., 1.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void NegativeIntegerAdderTest() {
+ Double assumed = -10.;
+ Double actual = ScientificFunctions.add(0., -10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SubtractionTestPositiveReturn() {
+ Double assumed = 1.;
+ Double actual = ScientificFunctions.subtract(3., 2.);
+ Assert.assertEquals(assumed, actual);
+
+ }
+
+ @Test
+ public void SubtractionTestZeroReturn() {
+ Double assumed = 0.;
+ Double actual = ScientificFunctions.subtract(3., 3.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SubtractionTestNegativeReturn() {
+ Double assumed = -1.;
+ Double actual = ScientificFunctions.subtract(3., 4.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void MultiplicationPositiveReturn() {
+ Double assumed = 16.;
+ Double actual = ScientificFunctions.multiply(8., 2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void MultiplicationZeroReturn() {
+ Double assumed = 0.;
+ Double actual = ScientificFunctions.multiply(0., 3.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void MultiplicationNegativeReturn() {
+ Double assumed = -9.;
+ Double actual = ScientificFunctions.multiply(-3., 3.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void MultiplicationBothNegativeNumbers() {
+ Double assumed = 9.;
+ Double actual = ScientificFunctions.multiply(-3., -3.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void DivisionPositiveReturnWholeNumber() {
+ Double assumed = 5.;
+ Double actual = ScientificFunctions.divide(10., 2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void DivisionPositiveReturnDecimal() {
+ Double assumed = 1.5;
+ Double actual = ScientificFunctions.divide(3., 2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void squareRootReturnPositiveWholeNumber() {
+ Double assumed = 3.;
+ Double actual = ScientificFunctions.squareRoot(9.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void squareRootReturnPositiveDecimal() {
+ Double assumed = 3.1622776601683795;
+ Double actual = ScientificFunctions.squareRoot(10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SquareReturnPositiveWholeNumber() {
+ Double assumed = 4.;
+ Double actual = ScientificFunctions.square(2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SquareReturnNegativeWholeNumber() {
+ Double assumed = -25.;
+ Double actual = ScientificFunctions.square(-5.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SquareReturnPositiveDecimal() {
+ Double assumed = 30.25;
+ Double actual = ScientificFunctions.square(5.5);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SquareReturnNegativeDecimal() {
+ Double assumed = -30.25;
+ Double actual = ScientificFunctions.square(-5.5);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ChangeSignFromPositive() {
+ Double assumed = -5.;
+ Double actual = ScientificFunctions.changeSign(5.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ChangeSignFromNegative() {
+ Double assumed = 5.;
+ Double actual = ScientificFunctions.changeSign(-5.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SinePositiveNumber() {
+ Double assumed = -0.5440211108893698;
+ Double actual = ScientificFunctions.sine(10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SineNegativeNumber() {
+ Double assumed = 0.5440211108893698;
+ Double actual = ScientificFunctions.sine(-10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void SineZeroNumber() {
+ Double assumed = 0.;
+ Double actual = ScientificFunctions.sine(0.);
+ Assert.assertEquals(assumed, actual);
+ }
+/*
+ @Test
+ public void squareRootReturnZero(){
+ String assumed = "Whatever logic my boys put";
+ Double actual = ScientificFunctions.squareRoot(10. );
+ Assert.assertEquals( assumed, actual);
+ }*/
+
+/*
+ @Test
+ public void squareRootReturnNegative(){
+ String assumed = "Whatever logic my boys put";
+ Double actual = ScientificFunctions.squareRoot(10. );
+ Assert.assertEquals( assumed, actual);
+ }*/
+
+ @Test
+ public void CosineNegativeNumber() {
+ Double assumed = -0.8390715290764524;
+ Double actual = ScientificFunctions.cosine(-10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void CosinePositiveNumber() {
+ Double assumed = -0.8390715290764524;
+ Double actual = ScientificFunctions.cosine(10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void CosineZeroNumber() {
+ Double assumed = 1.;
+ Double actual = ScientificFunctions.cosine(0.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void TangentZeroNumber() {
+ Double assumed = 0.;
+ Double actual = ScientificFunctions.tangent(0.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void TangentPositiveNumber() {
+ Double assumed = 0.6483608274590866;
+ Double actual = ScientificFunctions.tangent(10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void TangentNegativeNumber() {
+ Double assumed = -0.6483608274590866;
+ Double actual = ScientificFunctions.tangent(-10.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentPositiveNumbers() {
+ Double assumed = 4.;
+ Double actual = ScientificFunctions.exponent(2., 2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentNegativeNumbers() {
+ Double assumed = 4.;
+ Double actual = ScientificFunctions.exponent(-2., 2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentNegativeExponentPositiveNumber() {
+ Double assumed = .25;
+ Double actual = ScientificFunctions.exponent(2., -2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentNegativeExponentNegativeNumber() {
+ Double assumed = .25;
+ Double actual = ScientificFunctions.exponent(-2., -2.);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentZeroPositiveNumber() {
+ Double assumed = 1.;
+ Double actual = ScientificFunctions.exponent(2., .0);
+ Assert.assertEquals(assumed, actual);
+ }
+
+ @Test
+ public void ExponentZeroZeroNumber() {
+ Double assumed = 1.;
+ Double actual = ScientificFunctions.exponent(0., .0);
+ Assert.assertEquals(assumed, actual);
+ }
+}
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
index 94e8d987..64dfa486 100644
--- a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
@@ -1,7 +1,22 @@
package com.zipcodewilmington.scientific_calculator;
+import com.zipcodewilmington.scientificcalculator.CoreFunctions;
+import org.junit.Assert;
+import org.junit.Test;
+
/**
* Created by leon on 2/9/18.
*/
public class TestMainApplication {
+ CoreFunctions coreFunctions = new CoreFunctions();
+/*
+ @Test
+ public void adderTest(){
+ int assumed = 3;
+ int actual = coreFunctions.Add(1 ,2);
+ Assert.assertEquals( assumed, actual);
+ }
+ */
+
}
+