diff --git a/pom.xml b/pom.xml
index b92b052..2321a62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,12 @@
4.12
test
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.8.1
+ test
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/CalcFunc.java b/src/main/java/com/zipcodewilmington/scientificcalculator/CalcFunc.java
new file mode 100644
index 0000000..9d53fc2
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/CalcFunc.java
@@ -0,0 +1,71 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class CalcFunc {
+
+ public void displayMainMenu () {
+ System.out.println("********************");
+ System.out.println("Welcome to the JAVA CALC.");
+ System.out.println("********************");
+ System.out.println("MAIN MENU:");
+ System.out.println("1. Main Calculator");
+ System.out.println("2. Scientific Calculator");
+ System.out.println("3. Custom Features");
+ System.out.println("4. End Application");
+// System.out.println("3. Use Memory");
+ System.out.println("********************");
+ System.out.println("Select an option:");
+ }
+
+ public void displayOperations (){
+ System.out.println("Type an operator:");
+ System.out.println("+ / - / x / %");
+ System.out.println("A. Square");
+ System.out.println("B. Square Root");
+ System.out.println("C. Exponentiation");
+ System.out.println("D. Inverse");
+ }
+
+ public void displayMemoryMenu () {
+ System.out.println("Select an option:");
+ System.out.println("1. M+");
+ System.out.println("2. MC");
+ System.out.println("3. MRC");
+ }
+
+ public void displaySciMenu () {
+ System.out.println("********************");
+ System.out.println("1. Change Display Mode");
+ System.out.println("2. Trigonometric Functions");
+ System.out.println("3. Logarithmic Functions");
+ System.out.println("4. Factorial Function");
+ System.out.println("5. Quit to Main Menu");
+ System.out.println("********************");
+ }
+
+ public void displaySciDisplayMode (){
+ System.out.println("Choose Display Options:");
+ System.out.println("1. Binary");
+ System.out.println("2. Octal");
+ System.out.println("3. Decimal");
+ System.out.println("4. Hexadecimal");
+ }
+
+ public void displayTrigMenu (){
+ System.out.println("Choose Trigonometric Function:");
+ System.out.println("1. Sine");
+ System.out.println("2. Cosine");
+ System.out.println("3. Tangent");
+ System.out.println("4. Inverse Sine");
+ System.out.println("5. Inverse Cosine");
+ System.out.println("6. Inverse Tangent");
+ }
+
+ public void displayLogMenu (){
+ System.out.println("Choose Logarithmic Functions:");
+ System.out.println("1. Log");
+ System.out.println("2. Inverse Log");
+ System.out.println("3. Natural Log");
+ System.out.println("4. Inverse Natural Log");
+ }
+
+}
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 0000000..b93eca3
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java
@@ -0,0 +1,99 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import static java.lang.Math.sqrt;
+
+public class Calculator {
+ //this is Coreye's CODE!!!! because his Git doesn't work
+ //anytime we do Calculator object just know it's from Coreye's code
+
+ public double add(double a, double b) {
+ System.out.println(">>> " + (a + b));
+ return a + b;
+ }
+ public double subtract(double a, double b) {
+ System.out.println(">>> " + (a - b)); // method to subtract two numbers
+ return a-b;
+ }
+ public double multiply(double a, double b) { //method to multiply two numbers
+ System.out.println(">>> " + (a * b));
+ return a * b;
+ }
+ public double divide(double a, double b) {
+ if (b == 0) {
+ System.out.println("ERROR!!!");
+ } else {
+ System.out.println(">>> " + (a / b));
+ }
+ return a / b;
+ }
+
+ public double squareRoot(double num) {
+ if (num < 0) {
+ throw new IllegalArgumentException("Square root of a negative number is not real");
+ }
+ return Math.sqrt(num);
+ }
+
+ public static double squareRootResult ( double x){
+ System.out.println(sqrt(x));
+ return sqrt(x);
+ }
+
+
+ public double square(double a) {
+ return a * a;
+ }
+
+ public double exponentiate(double base, double exponent) {
+ System.out.println(Math.pow(base, exponent));
+ return Math.pow(base, exponent);
+ }
+
+ public double inverse(double num){
+ return 1 / num;
+ }
+
+ public static double invertDouble ( double x){
+// System.out.println("original number: " + x);
+// System.out.println("inverted number: " + (x *= -1));
+ System.out.println(x * -1);
+ return x * -1; //it works!
+ }
+
+
+ // THIS IS AN ATTEMPT TO GET MEMORY VARIABLE WORKING!!!
+// if (scanner.hasNextDouble){
+// displayVar = scanner.nextDouble();
+// System.out.println(displayVar);
+// } else if (scanner.hasNext()){
+// String memInput = scanner.next();
+// if (memInput.equalsIgnoreCase(m)){
+// displayVar = memoryVariable;
+// System.out.println(displayVar);
+// } else {
+// result = displayVar;
+// }
+// }
+
+
+
+ //THIS SHOULD WORK FOR VARIABLE 2 INPUT THEORETICALLY
+// System.out.println("Select another number: [or type M: MRC]");
+// if (scanner.hasNextDouble()){
+// displayVar2 = scanner.nextDouble();
+// System.out.println(displayVar2);
+// } else if (scanner.hasNext()){
+// String memInput2 = scanner.next();
+// if (memInput2.equalsIgnoreCase("m")){
+// displayVar2 = memoryVariable;
+// System.out.println(displayVar2);
+// }
+// }
+
+
+
+}
+
+
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
index 83f0e97..c8eaf70 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
@@ -2,7 +2,7 @@
import java.util.Scanner;
-/**
+/**testing git pull request
* Created by leon on 2/9/18.
*/
public class Console {
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/LogCalc.java b/src/main/java/com/zipcodewilmington/scientificcalculator/LogCalc.java
new file mode 100644
index 0000000..6a9a089
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/LogCalc.java
@@ -0,0 +1,45 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import static java.util.Calendar.PM;
+
+public class LogCalc {
+
+ //log
+
+ //inverse logarithm
+
+ //natural logarithm
+
+ //inverse natural logarithm
+
+
+ //
+// public double squareRoot(double num) {
+// return Math.sqrt(num);
+// }
+// public double square(double a) {
+// return a * a;
+// }
+// public double exponentiate(double base, double exponent) {
+// return Math.pow(base, exponent);
+// }
+// public double inverse(double a){
+// return 1/a;
+// }
+ public double logarithm(double base, double number) {return Math.log(number) / Math.log(base);}
+
+ public double inverseLogarithm(double base, double logValue) {
+ return Math.pow(base, logValue);
+ }
+
+ public double naturalLogarithm(double number) {
+ return Math.log(number);
+ }
+
+ public double inverseNaturalLogarithm (double number){return Math.exp(number); }
+
+
+}
+
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
index 5f42132..da46e81 100644
--- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java
@@ -1,17 +1,336 @@
package com.zipcodewilmington.scientificcalculator;
+//import java.util.Scanner;
+//
+//import static java.lang.Math.*;
+
+import com.zipcodewilmington.scientificcalculator.ScientificCalculator;
/**
* 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.");
+public static void main (String [] args) {
+ ScientificCalculator fullProject = new ScientificCalculator();
- 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);
- }
+// fullProject.run();
+}
}
+//
+// public static void displayMainMenu(){
+// System.out.println("********************");
+// System.out.println("Welcome to the JAVA CALC.");
+// System.out.println("********************");
+// System.out.println("MAIN MENU:");
+// System.out.println("1. Calculator");
+// System.out.println("2. Scientific Calculator");
+//// System.out.println("3. Use Memory");
+// System.out.println("********************");
+// System.out.println("Select an option:");
+// }
+// public static void displayMemoryMenu(){
+// System.out.println("Select an option:");
+// System.out.println("1. M+");
+// System.out.println("2. MC");
+// System.out.println("3. MRC");
+// }
+//
+// public static double add(double a, double b){
+//// System.out.println(">>> " + a + " + " + b + " = " + (a+b)); < fancier way to display result but nah
+// System.out.println(">>> " + (a + b));
+// return a + b;
+// }
+//
+// public static double subtract(double a, double b){
+// System.out.println(">>> " + (a - b));
+// return a - b;
+// }
+//
+// public static double multiply(double a, double b){
+// System.out.println(">>> " + (a * b));
+// return a * b;
+// }
+//
+// public static double divide(double a, double b){
+// if (b == 0){
+// System.out.println("ERROR!!!");
+// } else {
+// System.out.println(">>> " + (a / b));
+// }
+// return a / b;
+// }
+//
+// public static double invertDouble(double x){
+//// System.out.println("original number: " + x);
+//// System.out.println("inverted number: " + (x *= -1));
+// System.out.println(x * -1);
+// return x * -1; //it works!
+// }
+//
+// public static double squareRootResult(double x){
+// System.out.println(sqrt(x));
+// return sqrt(x);
+// }
+//
+// public static void displaySciMenu(){
+// System.out.println("1. Change Display Mode");
+// System.out.println("2. Trigonometric Functions");
+// System.out.println("3. Logarithmic Functions");
+// System.out.println("4. Factorial Function");
+// }
+//
+// public static void main(String[] args) {
+//
+// Scanner scanner = new Scanner(System.in);
+//
+//
+//
+//// 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);
+// String operatorSelect;
+// double answer;
+// boolean calculatorOn = false;
+// boolean scientificOn = false;
+// boolean memoryOn = false;
+// int userOption;
+// double memoryVariable = 0;
+// boolean binaryOn = false;
+// boolean octalOn = false;
+// boolean decimalOn = true;
+// boolean hexadecimalOn = false;
+//
+//
+// displayMainMenu();
+// userOption = scanner.nextInt();
+// switch (userOption){
+// case 1: calculatorOn = true;
+// break;
+// case 2: scientificOn = true;
+// break;
+// case 3:
+// memoryOn = true;
+// displayMemoryMenu();
+// break;
+// default:
+// System.out.println("Not an option.");
+// }
+//
+//
+// while (calculatorOn) {
+// Calculator calculator = new Calculator();
+//
+// double displayVar = 0;
+// double displayVar2 = 0;
+//
+// //for variable 1
+// System.out.println("Please enter a number:");
+// System.out.println(displayVar);
+// displayVar = scanner.nextDouble();
+// System.out.println(displayVar);
+//
+// //ask for inverse or not
+// System.out.println("Invert sign?");
+// System.out.println("Y/N:");
+// scanner.nextLine();
+// String userInvert = scanner.nextLine();
+// if (userInvert.equalsIgnoreCase("Y")) {
+// invertDouble(displayVar);
+// }
+//
+// //for operator
+// System.out.println("Type an operator:");
+// System.out.println("+");
+// System.out.println("-");
+// System.out.println("x");
+// System.out.println("%");
+// System.out.println("A. Square");
+// System.out.println("B. Square Root");
+// System.out.println("C. Exponentiation");
+// System.out.println("D. Inverse");
+//// scanner.nextLine();
+// operatorSelect = scanner.nextLine();
+// if (operatorSelect.equalsIgnoreCase("B")){
+// System.out.println(calculator.squareRoot(displayVar));
+// break;
+// } else if (operatorSelect.equalsIgnoreCase("A")){
+// System.out.println(calculator.square(displayVar));
+// break;
+// } else if (operatorSelect.equalsIgnoreCase("D")){
+// System.out.println(calculator.inverse(displayVar));
+// break;
+// }
+//
+// //for variable 2
+// System.out.println("Select another number:");
+// displayVar2 = scanner.nextDouble();
+// System.out.println(displayVar2); //new
+//
+// //inverse option for variable 2
+// System.out.println("Invert sign?");
+// System.out.println("Y/N:");
+// scanner.nextLine();
+// String userInvert2 = scanner.nextLine();
+// if (userInvert2.equalsIgnoreCase("Y")) {
+// displayVar2 = invertDouble(displayVar2);
+// }
+//
+//
+// //BASIC MATH OPERATIONS
+// double result;
+// if (operatorSelect.equals("+")) {
+// result = add(displayVar, displayVar2);
+// } else if (operatorSelect.equals("-")) {
+// result = subtract(displayVar, displayVar2);
+// } else if (operatorSelect.equals("x")){
+// result = multiply(displayVar, displayVar2);
+// } else if (operatorSelect.equals("%")){
+// result = divide(displayVar,displayVar2);
+// } else if (operatorSelect.equalsIgnoreCase("C")){
+// result = calculator.exponentiate(displayVar, displayVar2);
+// } else {
+// break;
+// }
+//
+// int nextOption;
+// System.out.println("Select an option:");
+// System.out.println("1. Clear");
+// System.out.println("2. Memory");
+// nextOption = scanner.nextInt();
+//
+// if (nextOption == 1) {
+// System.out.println("***CLEARED***");
+// } else if (nextOption == 2) {
+// int memorySelectOption;
+// displayMemoryMenu();
+// memorySelectOption = scanner.nextInt();
+// switch (memorySelectOption){
+// case 1:
+// memoryVariable = result;
+// System.out.println(">>> Memory Value Saved: " + memoryVariable);
+// break;
+// case 2:
+// memoryVariable = 0;
+// System.out.println(">>> Memory Value CLEARED.");
+// break;
+// case 3:
+// System.out.println(">>> Current Memory Value: " + memoryVariable);
+// break;
+// }
+//
+// }
+//
+// }
+//
+// while (scientificOn){
+// displaySciMenu();
+// Scientific scientific = new Scientific();
+// int sciUserOption = scanner.nextInt();
+// switch (sciUserOption){
+// case 1:
+// System.out.println("Choose Display Options:");
+// System.out.println("1. Binary");
+// System.out.println("2. Octal");
+// System.out.println("3. Decimal");
+// System.out.println("4. Hexadecimal");
+// int displayUserOption = scanner.nextInt();
+// switch (displayUserOption) {
+// case 1:
+// binaryOn = true;
+// System.out.println("Binary is " + binaryOn);
+// break;
+// case 2:
+// octalOn = true;
+// System.out.println("Octal is " + octalOn);
+// break;
+// case 3:
+// decimalOn = false;
+// System.out.println("Decimal is " + decimalOn);
+// break;
+// case 4:
+// hexadecimalOn = true;
+// System.out.println("Hexadecimal is " + hexadecimalOn);
+// break;
+// }
+// break;
+// case 2:
+// System.out.println("Choose Trigonometric Function:");
+// System.out.println("1. Sine");
+// System.out.println("2. Cosine");
+// System.out.println("3. Tangent");
+// System.out.println("4. Inverse Sine");
+// System.out.println("5. Inverse Cosine");
+// System.out.println("6. Inverse Tangent");
+// System.out.println("7. Switch Unit Modes");
+// int trigUserOption = scanner.nextInt();
+// switch (trigUserOption){
+// case 1:
+// System.out.println("Calculate sin of a number:");
+// double sinUser = scanner.nextDouble();
+// scientific.sin(sinUser);
+// break;
+// case 2:
+// System.out.println("Calculate cos of a number:");
+// double cosUser = scanner.nextDouble();
+// scientific.cos(cosUser);
+// break;
+// case 3:
+// System.out.println("Calculate tan of a number:");
+// double tanUser = scanner.nextDouble();
+// scientific.tan(tanUser);
+// break;
+// }
+// break;
+// case 3:
+// LogCalc logCalc = new LogCalc();
+// System.out.println("Choose Logarithmic Functions:");
+// System.out.println("1. Log");
+// System.out.println("2. Inverse Log");
+// System.out.println("3. Natural Log");
+// System.out.println("4. Inverse Natural Log");
+// int logUserOption = scanner.nextInt();
+// switch (logUserOption){
+// case 1://for LOG
+// System.out.println("Enter base number:");
+// double logA = scanner.nextDouble();
+// System.out.println("Enter second number:");
+// double logB = scanner.nextDouble();
+// System.out.println(">>> " + logCalc.logarithm(logA, logB));
+// break;
+// case 2://for INVERSE LOG
+// System.out.println("Enter base number:");
+// double logC = scanner.nextDouble();
+// System.out.println("Enter second number:");
+// double logD = scanner.nextDouble();
+// System.out.println(">>> " + logCalc.inverseLogarithm(logC, logD));
+// break;
+// case 3: //for NATURAL LOG
+// System.out.println("Enter a number:");
+// double logE = scanner.nextDouble();
+// System.out.println(">>> " + logCalc.naturalLogarithm(logE));
+// break;
+// case 4: //for INVERSE NATURAL LOG
+// System.out.println("Enter a number:");
+// double logF = scanner.nextDouble();
+// System.out.println(">>> " + logCalc.inverseNaturalLogarithm(logF));
+// break;
+// }
+// break;
+// case 4:
+// System.out.println("Enter a number:");
+// double factorialNum = scanner.nextDouble();
+// System.out.println(scientific.factorial(factorialNum));
+// break;
+// default:
+// System.out.println("Not an option.");
+// }
+// break;
+// }
+//
+//
+// }
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java
new file mode 100644
index 0000000..47eded5
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Scientific.java
@@ -0,0 +1,153 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import java.util.Scanner;
+
+public class Scientific {
+
+ public double sin(double a) { //sin method
+ double inRad = Math.sin(a); //calculate sin automatically in radian
+ double inDeg = Math.toRadians(a); // convert degree input into radian
+ Scanner radDeg = new Scanner(System.in);
+ System.out.println("Display in radians: R \nDisplay in degrees: D"); //Ask user if the want display in Radians or degrees
+ String entry = radDeg.nextLine();
+ if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+ System.out.println(">>> " + inRad);
+ } else if (entry.equalsIgnoreCase("D")) {
+ System.out.println(">>> " + Math.sin(inDeg)); //convert radians back to degrees
+ } else {
+ System.out.println("ERR");
+ }//print
+ return inRad;
+ }
+
+ public double cos(double a) { //cos method
+ double inRad = Math.cos(a);
+ double inDeg = Math.toRadians(a);//calculate cos automatically in radian
+ Scanner radDeg = new Scanner(System.in);
+ System.out.println("Display in radians: R \nDisplay in degrees: D"); //Ask user if the want display in Radians or degrees
+ String entry = radDeg.nextLine();
+ if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+ System.out.println(">>> " + inRad);
+ } else if (entry.equalsIgnoreCase("D")) {
+ System.out.println(">>> " + Math.cos(inDeg)); //convert radians to degrees
+ } else {
+ System.out.println("ERR");
+ }//print
+ return inRad;
+ }
+
+ public double tan(double a) { //tan method
+ double solution = Math.tan(a);
+ return solution;
+ }
+ public double degrees( double a) {
+ double degrees = Math.toDegrees(a);
+ return degrees;
+ }
+
+
+// double inDeg = Math.toRadians(a);//calculate tan automatically in radian
+// Scanner radDeg = new Scanner(System.in);
+// System.out.println("Display in radians: R \nDisplay in degrees: D"); //Ask user if the want display in Radians or degrees
+// String entry = radDeg.nextLine();
+// if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+// System.out.println(">>> " + inRad);
+// } else if (entry.equalsIgnoreCase("D")) {
+// System.out.println(">>> " + Math.tan(inDeg)); //convert radians to degrees
+// } else {
+// System.out.println("ERR")
+
+
+
+ public static double inSin(double a) { //sin method
+ double inRad = Math.asin(a); //calculate sin automatically in radian
+ double inDeg = Math.toRadians(a); // convert degree input into radian
+ Scanner radDeg = new Scanner(System.in);
+ System.out.println("Display in Radians: R \nDDisplay in Degrees: D"); //Ask user if the want display in Radians or degrees
+ String entry = radDeg.nextLine();
+ if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+ if (a >= -1 && a <= 1) {
+ System.out.println(">>> " + inRad);
+ } else {
+ System.out.println("ERROR: Must be between -1 and 1!");
+ }
+ } else if (entry.equalsIgnoreCase("D")) {
+ System.out.println(">>> " + Math.toDegrees(Math.asin(Math.sin(inRad))));
+ // System.out.println(">>> " + Math.asin(inDeg)); convert radians back to degrees
+ } else {
+ System.out.println("ERR");
+ }//print
+ return inRad;
+ }
+
+ public static double inCos(double a) { //sin method
+ double inRad = Math.acos(a); //calculate sin automatically in radian
+// double inDeg = Math.toDegrees(inRad); // convert degree input into radian
+// Scanner radDeg = new Scanner(System.in);
+// System.out.println("Display in Radians: R \nDisplay in Degrees: D"); //Ask user if the want display in Radians or degrees
+// String entry = radDeg.nextLine();
+// if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+// if (a >= -1 && a <= 1) { // arccos is between -1 and 1. outside of that range is NaN
+// System.out.println(">>> " + inRad);
+// } else {
+// System.out.println("ERROR! Must be between -1 & 1!");
+// }
+// } else if (entry.equalsIgnoreCase("D")) {
+// System.out.println(">>> " + inDeg);
+//// System.out.println(">>> " + Math.acos(inDeg)); //convert radians back to degrees
+// } else {
+// System.out.println("ERR");
+// }//print
+ return inRad;
+ }
+
+
+ public static double inTan(double a) { //sin method
+ double inRad = Math.atan(a); //calculate sin automatically in radian
+ double inDeg = Math.toDegrees(inRad); // convert degree input into radian
+ Scanner radDeg = new Scanner(System.in);
+ System.out.println("Display in Radians: R \nDisplay in Degrees: D"); //Ask user if
+ String entry = radDeg.nextLine();
+ if (entry.equalsIgnoreCase("R")) { //conditional statement based on user response
+ System.out.println(">>> " + inRad);
+ } else if (entry.equalsIgnoreCase("D")) {
+ System.out.println(">>> " + inDeg); //convert radians back to degrees
+ } else {
+ System.out.println("ERR");
+ }//print
+ return inRad;
+ }
+
+ public double switchUnits(double input){
+ double
+ }
+
+
+ public double factorial(double n){
+ double sum = 1;
+ for (int i = 1; i <= n; i++) {
+ sum *= i;
+ }
+ return sum;
+ }
+
+ public void convertToHex(double a){
+ int intValue = (int) Math.round(a); // convert to int by rounding the double
+ String hex = Integer.toHexString(intValue); //int to hex
+ System.out.println(hex);
+ }
+
+ public void convertToBin(double a){
+ int intValue = (int) Math.round(a);// convert to int by rounding the double
+ String binary = Integer.toBinaryString(intValue);//int to Binary
+ System.out.println(binary);
+ }
+
+ public void convertToOct(double a){
+ int intValue = (int) Math.round(a);// convert to int by rounding the double
+ String octal = Integer.toOctalString(intValue);//int to Octal
+ System.out.println(octal);
+ }
+
+
+}
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator.java
new file mode 100644
index 0000000..edd8c0b
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator.java
@@ -0,0 +1,385 @@
+package com.zipcodewilmington.scientificcalculator;
+import java.util.Scanner;
+import static java.lang.Math.*;
+
+public class ScientificCalculator {
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+ String operatorSelect;
+ double answer;
+ boolean calculatorOn = false;
+ boolean scientificOn = false;
+ boolean customOn = false;
+ boolean memoryOn = false;
+ int userOption;
+ double memoryVariable = 0;
+ boolean binaryOn = false;
+ boolean octalOn = false;
+ boolean decimalOn = true;
+ boolean hexadecimalOn = false;
+ CalcFunc calcFunc = new CalcFunc();
+ boolean firstAnswer = false;
+ double displayVar = 0;
+ double displayVar2 = 0;
+ double result;
+ boolean running = true;
+
+ while (running) {
+ calcFunc.displayMainMenu();
+ userOption = scanner.nextInt();
+ switch (userOption) {
+ case 1:
+ calculatorOn = true;
+ break;
+ case 2:
+ scientificOn = true;
+ break;
+ case 3:
+ customOn = true;
+ break;
+ case 4:
+ running = false;
+ break;
+ default:
+ System.out.println("Not an option.");
+ }
+
+
+ while (calculatorOn) {
+ Calculator calculator = new Calculator();
+
+
+ //for variable 1 - this one works :)
+// if (firstAnswer == false) {
+// System.out.println("Please enter a number:");
+// System.out.println(displayVar);
+// displayVar = scanner.nextDouble();
+// System.out.println(displayVar);
+// } else {
+// result = displayVar;
+// }
+
+ // This makes memory work and I fixed bug so Continue works as well
+ if (firstAnswer == false) {
+ System.out.println("Please enter a number: [or type M: MRC]");
+// System.out.println(displayVar); (testing a bug keep for reference)
+ System.out.println(0);
+
+ if (scanner.hasNextDouble()) {
+ displayVar = scanner.nextDouble();
+ System.out.println(displayVar);
+ } else if (scanner.hasNext()) {
+ String memInput = scanner.next();
+ if (memInput.equalsIgnoreCase("m")) {
+ displayVar = memoryVariable;
+ System.out.println(displayVar);
+ }
+ }
+ } else {
+ result = displayVar;
+ }
+
+
+// ask for inverse or not
+// System.out.println("Invert sign? Y/N");
+ scanner.nextLine();
+// String userInvert = scanner.nextLine();
+// if (userInvert.equalsIgnoreCase("Y")) {
+// calculator.invertDouble(displayVar);
+// }
+
+ //for operator
+ calcFunc.displayOperations();
+// scanner.nextLine();
+
+ operatorSelect = scanner.nextLine();
+ if (operatorSelect.equalsIgnoreCase("B")) {
+ System.out.println(">>> " + calculator.squareRoot(displayVar));
+ break;
+ } else if (operatorSelect.equalsIgnoreCase("A")) {
+ System.out.println(">>> " + calculator.square(displayVar));
+ break;
+ } else if (operatorSelect.equalsIgnoreCase("D")) {
+ System.out.println(">>> " + calculator.inverse(displayVar));
+ break;
+ }
+
+ //for variable 2 - the one that works :)
+// System.out.println("Select another number:");
+// displayVar2 = scanner.nextDouble();
+// System.out.println(displayVar2); //new
+
+ System.out.println("Select another number: [or type M: MRC]");
+ if (scanner.hasNextDouble()) {
+ displayVar2 = scanner.nextDouble();
+ System.out.println(displayVar2);
+ } else if (scanner.hasNext()) {
+ String memInput2 = scanner.next();
+ if (memInput2.equalsIgnoreCase("m")) {
+ displayVar2 = memoryVariable;
+ System.out.println(displayVar2);
+ }
+ }
+
+ //inverse option for variable 2
+// System.out.println("Invert sign?");
+// System.out.println("Y/N:");
+ scanner.nextLine();
+// String userInvert2 = scanner.nextLine();
+// if (userInvert2.equalsIgnoreCase("Y")) {
+// displayVar2 = calculator.invertDouble(displayVar2);
+// }
+
+
+ //BASIC MATH OPERATIONS
+ if (operatorSelect.equals("+")) {
+ result = calculator.add(displayVar, displayVar2);
+ } else if (operatorSelect.equals("-")) {
+ result = calculator.subtract(displayVar, displayVar2);
+ } else if (operatorSelect.equals("x")) {
+ result = calculator.multiply(displayVar, displayVar2);
+ } else if (operatorSelect.equals("%")) {
+ result = calculator.divide(displayVar, displayVar2);
+ } else if (operatorSelect.equalsIgnoreCase("C")) {
+ result = calculator.exponentiate(displayVar, displayVar2);
+ } else {
+ break;
+ }
+
+ int nextOption;
+ System.out.println("Select an option:");
+ System.out.println("1. Clear");
+ System.out.println("2. Memory");
+ System.out.println("3. Continue");
+ System.out.println("4. Invert (+/-)");
+ System.out.println("5. Quit");
+ nextOption = scanner.nextInt();
+
+ if (nextOption == 1) {
+ System.out.println("***CLEARED***");
+ firstAnswer = false;
+ displayVar = 0;
+ } else if (nextOption == 2) {
+ int memorySelectOption;
+ calcFunc.displayMemoryMenu();
+ memorySelectOption = scanner.nextInt();
+ switch (memorySelectOption) {
+ case 1:
+ memoryVariable = result;
+ System.out.println(">>> Memory Value Saved: " + memoryVariable);
+ displayVar = 0;
+// System.out.println(displayVar); //just added this idk
+ break;
+ case 2:
+ memoryVariable = 0;
+ System.out.println(">>> Memory Value CLEARED.");
+ displayVar = 0; //THIS FIXED A BUG WOOHOO
+ break;
+// case 3:
+// System.out.println(">>> Current Memory Value: " + memoryVariable);
+// displayVar = memoryVariable;
+// firstAnswer = true;
+// System.out.println(displayVar);
+// System.out.println("Type C to continue.");
+// break;
+ }
+
+ } else if (nextOption == 3) {
+ firstAnswer = true;
+ displayVar = result;
+ System.out.println(displayVar);
+ } else if (nextOption == 4) {
+ firstAnswer = true;
+ displayVar = calculator.invertDouble(result);
+// System.out.println(displayVar);
+ } else if (nextOption == 5) {
+ firstAnswer = false;
+ calculatorOn = false;
+ displayVar = 0;
+ break;
+ }
+
+ }
+
+
+ while (scientificOn) {
+ calcFunc.displaySciMenu();
+ Scientific scientific = new Scientific();
+ int sciUserOption = scanner.nextInt();
+ switch (sciUserOption) {
+ case 1:
+// scientific.convertToInt(69);
+ calcFunc.displaySciDisplayMode();
+ int displayUserOption = scanner.nextInt();
+ switch (displayUserOption) {
+ case 1:
+ binaryOn = true;
+ break;
+ case 2:
+ octalOn = true;
+ break;
+ case 3:
+ decimalOn = false;
+ break;
+ case 4:
+ hexadecimalOn = true;
+ break;
+ }
+ break;
+ case 2:
+ calcFunc.displayTrigMenu();
+ int trigUserOption = scanner.nextInt();
+ switch (trigUserOption) {
+ case 1:
+ System.out.println("Calculate sin of a number:");
+ double sinUser = scanner.nextDouble();
+ scientific.sin(sinUser);
+ break;
+ case 2:
+ System.out.println("Calculate cos of a number:");
+ double cosUser = scanner.nextDouble();
+ scientific.cos(cosUser);
+ break;
+ case 3:
+ System.out.println("Calculate tan of a number:");
+ double tanUser = scanner.nextDouble();
+ scientific.tan(tanUser);
+ break;
+ case 4:
+ System.out.println("Calculate Inverse sin of a number:");
+ double InSinUser = scanner.nextDouble();
+ scientific.inSin(InSinUser);
+ break;
+ case 5:
+ System.out.println("Calculate Inverse cos of a number:");
+ double InCosUser = scanner.nextDouble();
+ scientific.inCos(InCosUser);
+ break;
+ case 6:
+ System.out.println("Calculate Inverse tan of a number:");
+ double InTanUser = scanner.nextDouble();
+ scientific.inTan(InTanUser);
+ break;
+ }
+ break;
+ case 3:
+ LogCalc logCalc = new LogCalc();
+ calcFunc.displayLogMenu();
+ int logUserOption = scanner.nextInt();
+ switch (logUserOption) {
+ case 1://for LOG
+ System.out.println("Enter base number:");
+ double logA = scanner.nextDouble();
+ System.out.println("Enter second number:");
+ double logB = scanner.nextDouble();
+ System.out.println(">>> " + logCalc.logarithm(logA, logB));
+ break;
+ case 2://for INVERSE LOG
+ System.out.println("Enter base number:");
+ double logC = scanner.nextDouble();
+ System.out.println("Enter second number:");
+ double logD = scanner.nextDouble();
+ System.out.println(">>> " + logCalc.inverseLogarithm(logC, logD));
+ break;
+ case 3: //for NATURAL LOG
+ System.out.println("Enter a number:");
+ double logE = scanner.nextDouble();
+ System.out.println(">>> " + logCalc.naturalLogarithm(logE));
+ break;
+ case 4: //for INVERSE NATURAL LOG
+ System.out.println("Enter a number:");
+ double logF = scanner.nextDouble();
+ System.out.println(">>> " + logCalc.inverseNaturalLogarithm(logF));
+ break;
+ }
+ break;
+ case 4:
+ System.out.println("Enter a number:");
+ double factorialNum = scanner.nextDouble();
+ System.out.println(scientific.factorial(factorialNum));
+ break;
+ case 5:
+ scientificOn = false;
+ break;
+ default:
+ System.out.println("Not an option.");
+ }
+// scientificOn = false;
+// break;
+ }
+
+ while (customOn) {
+ boolean emojiOn = false;
+ boolean riddleOn = false;
+ System.out.println("Welcome to the custom menu!");
+ System.out.println("1. Emojis");
+ System.out.println("2. Riddle Me");
+ System.out.println("3. Back to Main Menu");
+ int customOption = scanner.nextInt();
+ switch (customOption) {
+ case 1:
+ emojiOn = true;
+ case 2:
+ riddleOn = true;
+ case 3:
+ customOn = false;
+ }
+ while (emojiOn) {
+ System.out.println("Type an emoji: [Q to Quit]");
+ Scanner smile = new Scanner(System.in);
+ String emoji = smile.nextLine();
+ if (emoji.equals(":)") || emoji.equals("(:")) {
+ System.out.println("\uD83D\uDE42");
+ } else if (emoji.equals(":(") || emoji.equals("):")) {
+ System.out.println("\u2639");
+ } else if (emoji.equals(";)") || emoji.equals("(;")) {
+ System.out.println("\uD83D\uDE09");
+ } else if (emoji.equals("<3")) {
+ System.out.println("\u2764\uFE0F");
+ } else if (emoji.equalsIgnoreCase("q")) {
+ riddleOn = false;
+ break;
+ }}
+
+ while (riddleOn) {
+ System.out.println("********************");
+ System.out.println("If you can guess our riddle- YOU WIN!");
+ System.out.println("I am the start of everything \n the end of everywhere. \n I'm the beginning of eternity, \n the end of time and space. \n What am I?");
+ System.out.println("********************");
+ System.out.println("Press Q to quit.");
+ scanner.nextLine();
+// scanner.nextLine();
+ String pressQ = scanner.nextLine();
+ switch (pressQ) {
+ case "q":
+ case "Q":
+ System.out.println(">>> Exiting Riddle Menu...");
+ riddleOn = false;
+ customOn = true;
+ break;
+ case "e":
+ case "E":
+ riddleOn = false;
+ customOn = true;
+ System.out.println("***** YOU WON!!! *****");
+ System.out.println("Press any key to exit.");
+ String userExit = scanner.nextLine();
+ break;
+ default:
+ riddleOn = false;
+ customOn = true;
+ System.out.println(">>> Wrong.");
+ System.out.println("Press any key to exit.");
+ String userExit2 = scanner.nextLine();
+ }
+ }
+// customOn = false;
+// break;
+ }
+ }
+
+ }
+
+ }
+
+
diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/TrigCalc.java b/src/main/java/com/zipcodewilmington/scientificcalculator/TrigCalc.java
new file mode 100644
index 0000000..0e97ef9
--- /dev/null
+++ b/src/main/java/com/zipcodewilmington/scientificcalculator/TrigCalc.java
@@ -0,0 +1,7 @@
+package com.zipcodewilmington.scientificcalculator;
+
+public class TrigCalc {
+
+//Test 2
+
+}
diff --git a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
index 94e8d98..c724594 100644
--- a/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
+++ b/src/test/java/com/zipcodewilmington/scientific_calculator/TestMainApplication.java
@@ -1,7 +1,30 @@
package com.zipcodewilmington.scientific_calculator;
+import com.zipcodewilmington.scientificcalculator.MainApplication;
+import com.zipcodewilmington.scientificcalculator.ScientificCalculator;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+import java.util.Random;
+
/**
* Created by leon on 2/9/18.
*/
+
public class TestMainApplication {
+
+ @Test
+ void testAdd(){
+ ScientificCalculator mainApp = new ScientificCalculator();
+ Random random = new Random();
+
+ int a = random.nextInt(1000);
+ int b = random.nextInt(1000);
+ int result = a + b;
+ System.out.println(a + " + " + b + " = " + result);
+// assertEquals(result, mainApp.add(a,b), "Error!!!");
+ }
+
+ //I HAD TO SET TEST FOLDER TO TEST SOURCE AND ONCE I MARKED THAT IT WORKED
+
+
}
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/CalculatorTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/CalculatorTest.java
new file mode 100644
index 0000000..99224db
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/CalculatorTest.java
@@ -0,0 +1,98 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+
+public class CalculatorTest extends TestCase {
+
+ public void testAdd() {
+
+ Calculator calculator = new Calculator();
+ double a = 5;
+ double b = 10;
+
+ double result = calculator.add(a, b);
+ assertEquals(15.0, result); //passed test
+ }
+
+ public void testSubtract() {
+ Calculator calculator = new Calculator();
+ double a = 5;
+ double b = 10;
+
+ double result = calculator.subtract(a, b);
+ assertEquals(-5.0, result); //passed test
+ }
+
+ public void testMultiply() {
+ Calculator calculator = new Calculator();
+ double a = 5;
+ double b = 10;
+
+ double result = calculator.multiply(a, b);
+ assertEquals(50.0, result); //passed test
+ }
+
+ public void testDivide() {
+ Calculator calculator = new Calculator();
+ double a = 5;
+ double b = 10;
+
+ double result = calculator.divide(a, b);
+ assertEquals(0.5, result); //passed test
+ }
+
+ public void testNegativeNumberSquareRoot() {
+ var calculator = new Calculator(); //Testing for illegal argument
+ assertThrows(IllegalArgumentException.class,
+ () -> {
+ calculator.squareRoot(-5);// cannot do square root of negative number
+ }); //test passed
+ }
+
+
+ public void testSquareRootResult() {
+ Calculator calculator = new Calculator();
+ double a = 25;
+
+ double result = calculator.squareRoot(a);
+ assertEquals(5.0, result); //passed test
+ }
+
+ public void testSquare() {
+ Calculator calculator = new Calculator();
+ double a = 5;
+
+ double result = calculator.square(a);
+ assertEquals(25.0, result); //passed test
+ }
+
+ public void testExponentiate() {
+ Calculator calculator = new Calculator();
+ double a = 2;
+ double b = 4;
+
+ double result = calculator.exponentiate(a, b);
+ assertEquals(16.0, result); //passed test
+ }
+
+ public void testInverse() {
+ Calculator calculator = new Calculator();
+ double a = 2;
+
+
+ double result = calculator.inverse(a);
+ assertEquals(0.5, result); //passed test
+ }
+
+ public void testInvertDouble() {
+ Calculator calculator = new Calculator();
+ double a = 2;
+
+ double result = calculator.invertDouble(a);
+ assertEquals(-2.0, result); //passed test
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/LogCalcTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/LogCalcTest.java
new file mode 100644
index 0000000..c668c8f
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/LogCalcTest.java
@@ -0,0 +1,45 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import junit.framework.TestCase;
+
+public class LogCalcTest extends TestCase {
+
+ public void testLogarithm() {
+
+ LogCalc log = new LogCalc();
+ double base = 10;
+ double number = 5;
+
+ double result = log.logarithm(base,number);
+ assertEquals(Math.log10(5), result, .0001); //Test Passed
+ }
+
+ public void testInverseLogarithm() {
+ LogCalc invlog = new LogCalc();
+ double base = 10;
+ double logVal = 5;
+ double expected = Math.pow(base, logVal);
+
+
+ double result = invlog.inverseLogarithm(base,logVal);
+ assertEquals(expected, result, .0001); /// Test Passed
+ }
+
+ public void testNaturalLogarithm() {
+ LogCalc naturalLog = new LogCalc();
+ double a = 10;
+
+ double result = naturalLog.naturalLogarithm(a);
+ assertEquals(Math.log(10), result); //test passed
+ }
+
+ public void testInverseNaturalLogarithm() {
+ LogCalc invNaturalLog = new LogCalc();
+ double a = 10;
+ double expected = Math.exp(a);
+
+
+ double result = invNaturalLog.inverseNaturalLogarithm(a);
+ assertEquals(expected, result, .0001); //// Test passed
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/MainApplicationTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/MainApplicationTest.java
new file mode 100644
index 0000000..d0b2bff
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/MainApplicationTest.java
@@ -0,0 +1,12 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class MainApplicationTest {
+
+ @Test
+ void displayMainMenu() {
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/zipcodewilmington/scientificcalculator/ScientificTest.java b/src/test/java/com/zipcodewilmington/scientificcalculator/ScientificTest.java
new file mode 100644
index 0000000..60e050b
--- /dev/null
+++ b/src/test/java/com/zipcodewilmington/scientificcalculator/ScientificTest.java
@@ -0,0 +1,64 @@
+package com.zipcodewilmington.scientificcalculator;
+
+import junit.framework.TestCase;
+import org.junit.Assert;
+
+public class ScientificTest extends TestCase {
+
+// public void testSin() {
+//
+// Scientific calculator = new Scientific();
+// double a =35; //angle in degrees
+// double expected = Math.sin(Math.toRadians(a));
+//
+// double result = calculator.sin(Math.toRadians(a));
+// assertEquals(expected, result, .00001 ); // Can't get passed the 'R' or 'D' display screen
+// } //Unable to test due to interactive display screen??
+
+ public void testCos() {//Unable to test due to interactive display screen??
+ }
+
+ public void testTan() {//Unable to test due to interactive display screen??
+ }
+
+ public void testInSin() {//Unable to test due to interactive display screen??
+ }
+
+ public void testInCos() {//Unable to test due to interactive display screen??
+ }
+
+ public void testInTan() {//Unable to test due to interactive display screen??
+ }
+
+ public void testFactorial() {
+ Scientific calculator = new Scientific();
+ double a = 5;
+
+ double result = calculator.factorial(a);
+ assertEquals(120.0, result); //passed test
+ }
+
+ public void testConvertToHex() {
+ Scientific convertToHex = new Scientific();
+ String expected = "32"; // String hex number
+
+ String actual = Integer.toHexString(50); //Int actual number converted to string
+ Assert.assertEquals(expected, actual); //Test Passed
+ }
+
+ public void testConvertToBin() {
+ Scientific convertToBin = new Scientific();
+ String expected = "110010"; // String Binary number
+
+ String actual = Integer.toBinaryString(50); //Int actual number converted to string
+ Assert.assertEquals(expected, actual); ///Test Passed
+ }
+
+ public void testConvertToOct() {
+ Scientific convertToOct = new Scientific();
+ String expected = "62"; // String Octal number
+
+ String actual = Integer.toOctalString(50); //Int actual number converted to string
+ Assert.assertEquals(expected, actual); ///Test Passed
+ }
+}
\ No newline at end of file