From 1aa7d502767420ebf296511493c26a0b2a01c9f5 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sat, 11 Jul 2026 08:52:43 -0400 Subject: [PATCH 01/15] Accidentaly made this edits in master branch: Added Arthmetic class with simple calculations, and impelemented user input functionality and error handling to the getDoubleInput method. --- .../scientificcalculator/Arithmetic.java | 49 +++++++++++++++++ .../scientificcalculator/Calculator.java | 0 .../scientificcalculator/Console.java | 53 ++++++++++++++++++- 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java new file mode 100644 index 00000000..83222278 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.scientificcalculator; +public class Arithmetic { + + //fields + private double result; + + //constructor + //Sets the starting value for the calculation. + public Arithmetic(double initialValue) { + this.result = initialValue; + } + + //methods + + //addtion + public Arithmetic add(double num) { + this.result = this.result + num; + return this; // returns the object itself, enabling chaining like add(5).multiply(2) + } + + //subtraction + public Arithmetic subtract(double num) { + this.result = this.result - num; + return this; + } + + //multiplication + public Arithmetic multiply(double num) { + this.result = this.result * num; + return this; + } + + //division + public Arithmetic divide(double num) { + if (num == 0) { + throw new ArithmeticException("Denominator cannot be zero"); + } + this.result = this.result / num; + return this; + } + + //getResult() - will retrieve the final value after chaining + public double getResult() { + return this.result; + } + +} + + 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..e69de29b diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java index 83f0e97f..8a7c6623 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java @@ -1,5 +1,6 @@ package com.zipcodewilmington.scientificcalculator; +import java.util.InputMismatchException; import java.util.Scanner; /** @@ -7,14 +8,17 @@ */ public class Console { + // Prints the given output without a newline character public static void print(String output, Object... args) { System.out.printf(output, args); } + // Prints the given output followed by a newline character public static void println(String output, Object... args) { print(output + "\n", args); } + // Gets a string input from the user public static String getStringInput(String prompt) { Scanner scanner = new Scanner(System.in); println(prompt); @@ -22,11 +26,58 @@ public static String getStringInput(String prompt) { return userInput; } + // Gets an integer input from the user + // TODO: implement using scanner + Integer.parseInt (handle NumberFormatException) public static Integer getIntegerInput(String prompt) { return null; } + // Gets a double input from the user public static Double getDoubleInput(String prompt) { - return null; + // return null; + Scanner scanner = new Scanner(System.in); //this initalize input from the user. + println(prompt); //this prints the prompt to the console + + try { + Double userInput = scanner.nextDouble(); //this gets the user's input as a double + scanner.nextLine(); // consume the newline character + return userInput; + } catch (InputMismatchException e) { + scanner.nextLine(); + println("Invalid input. Please enter a valid number."); + return getDoubleInput(prompt); + } + } + + // //Calculations: Can't use this anymore because it's stateless :( back to the drawing board - Jaiden) + // public static Double getCalc(Double num1, Double num2) { + // double result = 0; + // int operation = 0; + + // switch (operation) { + // case 1: + // //addition + // result = num1 + num2; + // break; + // case 2: + // //subtraction + // result = num1 - num2; + // break; + // case 3: + // //multiplication + // result = num1 * num2; + // break; + // case 4: + // //division + // result = num1 / num2; + // break; + // default: + // System.out.println("Invalid operation"); + // } + + // return result; + // } + + } From abb684a6dea14495ef8e85f5b8bcb13bb5f85f72 Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 11 Jul 2026 08:50:56 -0400 Subject: [PATCH 02/15] Add multi-page scientific calculator menu --- .../scientificcalculator/Console.java | 61 +-- .../scientificcalculator/MainApplication.java | 482 +++++++++++++++++- 2 files changed, 478 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java index 8a7c6623..7509338f 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java @@ -1,6 +1,5 @@ package com.zipcodewilmington.scientificcalculator; -import java.util.InputMismatchException; import java.util.Scanner; /** @@ -8,17 +7,14 @@ */ public class Console { - // Prints the given output without a newline character public static void print(String output, Object... args) { System.out.printf(output, args); } - // Prints the given output followed by a newline character public static void println(String output, Object... args) { print(output + "\n", args); } - // Gets a string input from the user public static String getStringInput(String prompt) { Scanner scanner = new Scanner(System.in); println(prompt); @@ -26,58 +22,15 @@ public static String getStringInput(String prompt) { return userInput; } - // Gets an integer input from the user - // TODO: implement using scanner + Integer.parseInt (handle NumberFormatException) public static Integer getIntegerInput(String prompt) { - return null; + Scanner scanner = new Scanner(System.in); + print(prompt); + return scanner.nextInt(); } - // Gets a double input from the user - public static Double getDoubleInput(String prompt) { - // return null; - Scanner scanner = new Scanner(System.in); //this initalize input from the user. - println(prompt); //this prints the prompt to the console - - try { - Double userInput = scanner.nextDouble(); //this gets the user's input as a double - scanner.nextLine(); // consume the newline character - return userInput; - } catch (InputMismatchException e) { - scanner.nextLine(); - println("Invalid input. Please enter a valid number."); - return getDoubleInput(prompt); - } - + public static Double getDouble(String prompt) { + Scanner scanner = new Scanner(System.in); + println(prompt); + return scanner.nextDouble(); } - - // //Calculations: Can't use this anymore because it's stateless :( back to the drawing board - Jaiden) - // public static Double getCalc(Double num1, Double num2) { - // double result = 0; - // int operation = 0; - - // switch (operation) { - // case 1: - // //addition - // result = num1 + num2; - // break; - // case 2: - // //subtraction - // result = num1 - num2; - // break; - // case 3: - // //multiplication - // result = num1 * num2; - // break; - // case 4: - // //division - // result = num1 / num2; - // break; - // default: - // System.out.println("Invalid operation"); - // } - - // return result; - // } - - } diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 5f421325..be14b2fe 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -1,17 +1,477 @@ package com.zipcodewilmington.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."); - 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); + boolean programRunning = true; + + while (programRunning) { + + displayStartMenu(); + + String startChoice = + Console.getStringInput("Enter your choice: ") + .trim() + .toUpperCase(); + + switch (startChoice) { + + case "1": + startCalculator(); + break; + + case "0": + Console.println("Goodbye!"); + programRunning = false; + break; + + default: + Console.println("Please enter 0 or 1."); + } + } + } + + public static void displayStartMenu() { + + Console.println(""); + Console.println("===================================="); + Console.println(" SCIENTIFIC CALCULATOR"); + Console.println("===================================="); + Console.println("1. Enter Calculator"); + Console.println("0. Exit"); + Console.println("===================================="); + } + + public static void startCalculator() { + + boolean calculatorRunning = true; + + int currentPage = 1; + + while (calculatorRunning) { + + displayCurrentPage(currentPage); + + String choice = + Console.getStringInput("Enter selection: ") + .trim() + .toUpperCase(); + + switch (currentPage) { + + case 1: + currentPage = + handlePageOne( + choice, + currentPage + ); + + if (choice.equals("B")) { + calculatorRunning = false; + } + + break; + + case 2: + currentPage = + handlePageTwo( + choice, + currentPage + ); + + break; + + case 3: + currentPage = + handlePageThree( + choice, + currentPage + ); + + break; + + case 4: + currentPage = + handlePageFour( + choice, + currentPage + ); + + if (choice.equals("B")) { + calculatorRunning = false; + } + + break; + + default: + Console.println("Invalid page."); + currentPage = 1; + } + } + + Console.println("Returning to the start menu."); + } + + public static void displayCurrentPage(int currentPage) { + + switch (currentPage) { + + case 1: + displayBasicMenu(); + break; + + case 2: + displayTrigMenu(); + break; + + case 3: + displayInverseAndLogMenu(); + break; + + case 4: + displayNumberSystemAndMemoryMenu(); + break; + + default: + displayBasicMenu(); + } + } + + public static int handlePageOne( + String choice, + int currentPage + ) { + + switch (choice) { + + case "1": + Console.println("Addition selected."); + break; + + case "2": + Console.println("Subtraction selected."); + break; + + case "3": + Console.println("Multiplication selected."); + break; + + case "4": + Console.println("Division selected."); + break; + + case "5": + Console.println("Square root selected."); + break; + + case "6": + Console.println("Power selected."); + break; + + case "7": + Console.println("Modulo selected."); + break; + + case "C": + clearDisplay(); + break; + + case "N": + currentPage = 2; + break; + + case "B": + break; + + default: + Console.println("Invalid selection."); + } + + return currentPage; + } + + public static int handlePageTwo( + String choice, + int currentPage + ) { + + switch (choice) { + + case "1": + Console.println("Sine selected."); + break; + + case "2": + Console.println("Cosine selected."); + break; + + case "3": + Console.println("Tangent selected."); + break; + + case "4": + Console.println("Cosecant selected."); + break; + + case "5": + Console.println("Secant selected."); + break; + + case "6": + Console.println("Cotangent selected."); + break; + + case "7": + Console.println("Degrees mode selected."); + break; + + case "8": + Console.println("Radians mode selected."); + break; + + case "C": + clearDisplay(); + break; + + case "N": + currentPage = 3; + break; + + case "P": + currentPage = 1; + break; + + case "H": + currentPage = 1; + break; + + default: + Console.println("Invalid selection."); + } + + return currentPage; + } + + public static int handlePageThree( + String choice, + int currentPage + ) { + + switch (choice) { + + case "1": + Console.println("Inverse sine selected."); + break; + + case "2": + Console.println("Inverse cosine selected."); + break; + + case "3": + Console.println("Inverse tangent selected."); + break; + + case "4": + Console.println("Natural logarithm selected."); + break; + + case "5": + Console.println("Base-10 logarithm selected."); + break; + + case "6": + Console.println("Exponential function selected."); + break; + + case "7": + Console.println("Pi selected."); + break; + + case "8": + Console.println("Euler's number selected."); + break; + + case "C": + clearDisplay(); + break; + + case "N": + currentPage = 4; + break; + + case "P": + currentPage = 2; + break; + + case "H": + currentPage = 1; + break; + + default: + Console.println("Invalid selection."); + } + + return currentPage; + } + + public static int handlePageFour( + String choice, + int currentPage + ) { + + switch (choice) { + + case "1": + Console.println("Binary display selected."); + break; + + case "2": + Console.println("Octal display selected."); + break; + + case "3": + Console.println("Decimal display selected."); + break; + + case "4": + Console.println("Hexadecimal display selected."); + break; + + case "5": + Console.println("Memory store selected."); + break; + + case "6": + Console.println("Memory recall selected."); + break; + + case "7": + Console.println("Memory add selected."); + break; + + case "8": + Console.println("Memory reset selected."); + break; + + case "C": + clearDisplay(); + break; + + case "P": + currentPage = 3; + break; + + case "H": + currentPage = 1; + break; + + case "B": + break; + + default: + Console.println("Invalid selection."); + } + + return currentPage; + } + + public static void displayBasicMenu() { + + Console.println(""); + Console.println("===================================="); + Console.println(" SCIENTIFIC CALCULATOR"); + Console.println(" BASIC MATH - PAGE 1 OF 4"); + Console.println("===================================="); + Console.println("1. Addition"); + Console.println("2. Subtraction"); + Console.println("3. Multiplication"); + Console.println("4. Division"); + Console.println("5. Square Root"); + Console.println("6. Power"); + Console.println("7. Modulo"); + Console.println("------------------------------------"); + Console.println("C. Clear Display"); + Console.println("N. Next Page"); + Console.println("B. Back to Start Menu"); + Console.println("===================================="); + } + + public static void displayTrigMenu() { + + Console.println(""); + Console.println("===================================="); + Console.println(" SCIENTIFIC CALCULATOR"); + Console.println(" TRIGONOMETRY - PAGE 2 OF 4"); + Console.println("===================================="); + Console.println("1. Sine"); + Console.println("2. Cosine"); + Console.println("3. Tangent"); + Console.println("4. Cosecant"); + Console.println("5. Secant"); + Console.println("6. Cotangent"); + Console.println("7. Degrees Mode"); + Console.println("8. Radians Mode"); + Console.println("------------------------------------"); + Console.println("C. Clear Display"); + Console.println("N. Next Page"); + Console.println("P. Previous Page"); + Console.println("H. Return to Page 1"); + Console.println("===================================="); + } + + public static void displayInverseAndLogMenu() { + + Console.println(""); + Console.println("===================================="); + Console.println(" SCIENTIFIC CALCULATOR"); + Console.println(" ADVANCED MATH - PAGE 3 OF 4"); + Console.println("===================================="); + Console.println("1. Inverse Sine"); + Console.println("2. Inverse Cosine"); + Console.println("3. Inverse Tangent"); + Console.println("4. Natural Log"); + Console.println("5. Base-10 Log"); + Console.println("6. Exponential"); + Console.println("7. Pi"); + Console.println("8. Euler's Number"); + Console.println("------------------------------------"); + Console.println("C. Clear Display"); + Console.println("N. Next Page"); + Console.println("P. Previous Page"); + Console.println("H. Return to Page 1"); + Console.println("===================================="); + } + + public static void displayNumberSystemAndMemoryMenu() { + + Console.println(""); + Console.println("===================================="); + Console.println(" SCIENTIFIC CALCULATOR"); + Console.println(" NUMBER SYSTEMS/MEMORY - PAGE 4 OF 4"); + Console.println("===================================="); + Console.println("1. Display as Binary"); + Console.println("2. Display as Octal"); + Console.println("3. Display as Decimal"); + Console.println("4. Display as Hexadecimal"); + Console.println("5. Memory Store"); + Console.println("6. Memory Recall"); + Console.println("7. Memory Add"); + Console.println("8. Memory Reset"); + Console.println("------------------------------------"); + Console.println("C. Clear Display"); + Console.println("P. Previous Page"); + Console.println("H. Return to Page 1"); + Console.println("B. Back to Start Menu"); + Console.println("===================================="); + } + + public static void clearDisplay() { + + for (int i = 0; i < 30; i++) { + Console.println(""); + } + + Console.println("Display cleared."); } -} +} \ No newline at end of file From f4485c5f4cfed8a0e6eb664fef4eb2f056eb470c Mon Sep 17 00:00:00 2001 From: jaiden Date: Sat, 11 Jul 2026 09:33:40 -0400 Subject: [PATCH 03/15] fixed git merge conflicts on my branches --- .../scientificcalculator/Arithmetic.java | 49 +++++++++++++ .../scientificcalculator/Calculator.java | 0 .../scientificcalculator/Console.java | 69 ++++++++++++++++++- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java new file mode 100644 index 00000000..83222278 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.scientificcalculator; +public class Arithmetic { + + //fields + private double result; + + //constructor + //Sets the starting value for the calculation. + public Arithmetic(double initialValue) { + this.result = initialValue; + } + + //methods + + //addtion + public Arithmetic add(double num) { + this.result = this.result + num; + return this; // returns the object itself, enabling chaining like add(5).multiply(2) + } + + //subtraction + public Arithmetic subtract(double num) { + this.result = this.result - num; + return this; + } + + //multiplication + public Arithmetic multiply(double num) { + this.result = this.result * num; + return this; + } + + //division + public Arithmetic divide(double num) { + if (num == 0) { + throw new ArithmeticException("Denominator cannot be zero"); + } + this.result = this.result / num; + return this; + } + + //getResult() - will retrieve the final value after chaining + public double getResult() { + return this.result; + } + +} + + 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..e69de29b diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java index 83f0e97f..12424793 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java @@ -1,5 +1,6 @@ package com.zipcodewilmington.scientificcalculator; +import java.util.InputMismatchException; import java.util.Scanner; /** @@ -7,14 +8,17 @@ */ public class Console { + // Prints the given output without a newline character public static void print(String output, Object... args) { System.out.printf(output, args); } + // Prints the given output followed by a newline character public static void println(String output, Object... args) { print(output + "\n", args); } + // Gets a string input from the user public static String getStringInput(String prompt) { Scanner scanner = new Scanner(System.in); println(prompt); @@ -22,11 +26,72 @@ public static String getStringInput(String prompt) { return userInput; } + // Gets an integer input from the user + // TODO: implement using scanner + Integer.parseInt (handle NumberFormatException) public static Integer getIntegerInput(String prompt) { - return null; + // return null; + + Scanner scanner = new Scanner(System.in); + println(prompt); + + try { + Integer userInput = scanner.nextInt(); + scanner.nextLine(); + return userInput; + + } catch (InputMismatchException e) { + scanner.nextLine(); + println("Invalid input. Please enter a valid number"); + return getIntegerInput(prompt); + } } + // Gets a double input from the user public static Double getDoubleInput(String prompt) { - return null; + // return null; + Scanner scanner = new Scanner(System.in); //this initalize input from the user. + println(prompt); //this prints the prompt to the console + + try { + Double userInput = scanner.nextDouble(); //this gets the user's input as a double + scanner.nextLine(); // consume the newline character + return userInput; + } catch (InputMismatchException e) { + scanner.nextLine(); + println("Invalid input. Please enter a valid number."); + return getDoubleInput(prompt); + } + } + + // //Calculations: Can't use this anymore because it's stateless :( back to the drawing board - Jaiden) + // public static Double getCalc(Double num1, Double num2) { + // double result = 0; + // int operation = 0; + + // switch (operation) { + // case 1: + // //addition + // result = num1 + num2; + // break; + // case 2: + // //subtraction + // result = num1 - num2; + // break; + // case 3: + // //multiplication + // result = num1 * num2; + // break; + // case 4: + // //division + // result = num1 / num2; + // break; + // default: + // System.out.println("Invalid operation"); + // } + + // return result; + // } + + } From 89733593507b6b38b59d2186fef4ddeb3a51b229 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sat, 11 Jul 2026 13:30:47 -0400 Subject: [PATCH 04/15] Glued logic and I/0 for cases 1-4. Cases have been tested are functional (edge tests not completed yet). --- .../scientificcalculator/Arithmetic.java | 18 ++++++ .../scientificcalculator/Calculator.java | 7 +++ .../scientificcalculator/MainApplication.java | 62 ++++++++++++++++++- 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java index 83222278..9fee0652 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -39,6 +39,24 @@ public Arithmetic divide(double num) { return this; } + //square root + public Arithmetic squareRoot() { + this.result = Math.sqrt(this.result); + return this; + } + + //power + public Arithmetic power(double num) { + this.result = Math.pow(this.result, num); + return this; + } + + //modulo + public Arithmetic modulo(double num) { + this.result = this.result % num; + return this; + } + //getResult() - will retrieve the final value after chaining public double getResult() { return this.result; diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index e69de29b..b60dac69 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.scientificcalculator; + +public class Calculator { + + + +} diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 75cbc63d..4ddf8297 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -44,7 +44,7 @@ public static void displayStartMenu() { Console.println("===================================="); } //end displayStartMenu() - + public static void startCalculator() { boolean calculatorRunning = true; @@ -64,6 +64,7 @@ public static void startCalculator() { case 1: currentPage = + //where did handlePageOne come from? handlePageOne( choice, currentPage @@ -147,20 +148,79 @@ public static int handlePageOne( switch (choice) { + /* + where do the two numbers come from?: getDoubleInput(); + how many times do I neet to call it? Once, the c + where does the artithmetic object get created? + after I call .add(); how do I get the number back out to show to the user? + */ + case "1": Console.println("Addition selected."); + + //Logic/// + double num1 = Console.getDoubleInput("Enter first number"); + double num2 = Console.getDoubleInput("Enter second number"); + Arithmetic add = new Arithmetic(num1); + add.add(num2); + double result = add.getResult(); + String finalResult = String.valueOf(result); + Console.println(finalResult); + //Logic// + break; case "2": Console.println("Subtraction selected."); + + //Logic/// + double snum1 = Console.getDoubleInput("Enter first number"); + double snum2 = Console.getDoubleInput("Enter second number"); + Arithmetic sub = new Arithmetic(snum1); + sub.subtract(snum2); + double subResult = sub.getResult(); + String finalSubResult = String.valueOf(subResult); + Console.println(finalSubResult); + //Logic// + break; case "3": Console.println("Multiplication selected."); + + //Logic/// + double mnum1 = Console.getDoubleInput("Enter first number"); + double mnum2 = Console.getDoubleInput("Enter second number"); + Arithmetic multiply = new Arithmetic(mnum1); + multiply.multiply(mnum2); + double mResult = multiply.getResult(); + String finalMultiplySubResult = String.valueOf(mResult); + Console.println(finalMultiplySubResult); + //Logic// + break; case "4": Console.println("Division selected."); + + //Logic/// + double dnum1 = Console.getDoubleInput("Enter first number"); + double dnum2 = Console.getDoubleInput("Enter second number"); + + try { + Arithmetic divide = new Arithmetic(dnum1); + divide.divide(dnum2); + double dResult = divide.getResult(); + String finalDivideResult = String.valueOf(dResult); + Console.println(finalDivideResult); + } catch (ArithmeticException e) { + // TODO: handle exception + Console.println("Invalid input. You cannot divide by 0, please try again"); + + } + + //Logic// + break; case "5": From 778fa97d03f4e662b0bd5b4463b238803dda75a9 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sun, 12 Jul 2026 17:23:30 -0400 Subject: [PATCH 05/15] cases 5 -7 have been glued --- .../scientificcalculator/Arithmetic.java | 2 +- .../scientificcalculator/MainApplication.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java index 9fee0652..5358ae02 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -40,7 +40,7 @@ public Arithmetic divide(double num) { } //square root - public Arithmetic squareRoot() { + public Arithmetic squareRoot(double num) { this.result = Math.sqrt(this.result); return this; } diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 4ddf8297..8faddbcf 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -225,14 +225,44 @@ public static int handlePageOne( case "5": Console.println("Square root selected."); + //Logic/// tehcnically redunant but it's functional. + double sqrtnum1 = Console.getDoubleInput("Enter first number"); + Arithmetic squareRoot = new Arithmetic(sqrtnum1); + squareRoot.squareRoot(sqrtnum1); + double sqrtResult = squareRoot.getResult(); + String finalSquareRootResult = String.valueOf(sqrtResult); + Console.println(finalSquareRootResult); + //Logic// break; case "6": Console.println("Power selected."); + + //Logic/// + double powernum1 = Console.getDoubleInput("Enter first number"); + double powernum2 = Console.getDoubleInput("Enter second number"); + Arithmetic power = new Arithmetic(powernum1); + power.power(powernum2); + double powerResult = power.getResult(); + String finalPowerResult = String.valueOf(powerResult); + Console.println(finalPowerResult); + //Logic// + break; case "7": Console.println("Modulo selected."); + + //Logic/// + double modnum1 = Console.getDoubleInput("Enter first number"); + double modnum2 = Console.getDoubleInput("Enter second number"); + Arithmetic modulo = new Arithmetic(modnum1); + modulo.modulo(modnum2); + double moduloResult = modulo.getResult(); + String finalModuloResult = String.valueOf(moduloResult); + Console.println(finalModuloResult); + //Logic// + break; case "C": From 26428f9a2e5900c41c9937f45e2f842f3c4f12a8 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sun, 12 Jul 2026 17:28:56 -0400 Subject: [PATCH 06/15] cmmenting to pull correctly --- .../scientificcalculator/MainApplication.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 8faddbcf..8b012742 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -253,7 +253,10 @@ public static int handlePageOne( case "7": Console.println("Modulo selected."); - //Logic/// + // comment to push correctly + double numComment; + + //Logic/ double modnum1 = Console.getDoubleInput("Enter first number"); double modnum2 = Console.getDoubleInput("Enter second number"); Arithmetic modulo = new Arithmetic(modnum1); From f3c32bfbaf8badce978106fc2ea51f857788c092 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sun, 12 Jul 2026 17:57:23 -0400 Subject: [PATCH 07/15] Sine, Cosine, and Tangent have been glued --- .../scientificcalculator/Arithmetic.java | 42 ++++++++++++++++++- .../scientificcalculator/MainApplication.java | 18 ++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java index 5358ae02..8ba2971c 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -39,11 +39,13 @@ public Arithmetic divide(double num) { return this; } - //square root + //square root, tehcnically redunant but it's functional. + public Arithmetic squareRoot(double num) { - this.result = Math.sqrt(this.result); + this.result = Math.sqrt(num); return this; } + //power public Arithmetic power(double num) { @@ -57,6 +59,40 @@ public Arithmetic modulo(double num) { return this; } + public Arithmetic sine() { + this.result = Math.sin(this.result); + return this; + + } + + public Arithmetic cosine() { + this.result = Math.cos(this.result); + return this; + + } + + public Arithmetic tangent() { + this.result = Math.tan(this.result); + return this; + + } + + // public Arithmetic cosecant(double num) { + // this.result = Math.cos(this.result); + // return this; + + // } + + // public Arithmetic secant(double num) { + + // } + + // public Arithmetic cotangent(double num) { + + // } + + + //getResult() - will retrieve the final value after chaining public double getResult() { return this.result; @@ -65,3 +101,5 @@ public double getResult() { } + + diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 8b012742..80e03945 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -295,10 +295,28 @@ public static int handlePageTwo( case "1": Console.println("Sine selected."); + + double sineInput = Console.getDoubleInput("Enter first number"); + Arithmetic sine = new Arithmetic(sineInput); + + sine.sine(); + double sineResult = sine.getResult(); + String finalSineResult = String.valueOf(sineResult); + Console.println(finalSineResult); + break; case "2": Console.println("Cosine selected."); + + double cosineInput = Console.getDoubleInput("Enter first number"); + Arithmetic cosine = new Arithmetic(cosineInput); + + cosine.cosine(); + double cosineResult = cosine.getResult(); + String finalcoSineResult = String.valueOf(cosineResult); + Console.println(finalcoSineResult); + break; case "3": From 07e1a776a7bbff1b08a0a3e195cdf2aff3cebb9c Mon Sep 17 00:00:00 2001 From: jaiden Date: Sun, 12 Jul 2026 18:00:29 -0400 Subject: [PATCH 08/15] Trying to push S/CS/Tan again --- .../scientificcalculator/MainApplication.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 80e03945..6ff2a23a 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -309,6 +309,8 @@ public static int handlePageTwo( case "2": Console.println("Cosine selected."); + double CommitTest2; + double cosineInput = Console.getDoubleInput("Enter first number"); Arithmetic cosine = new Arithmetic(cosineInput); @@ -321,6 +323,15 @@ public static int handlePageTwo( case "3": Console.println("Tangent selected."); + + double tangentInput = Console.getDoubleInput("Enter first number"); + Arithmetic tangent = new Arithmetic(tangentInput); + + tangent.tangent(); + double tangentResult = tangent.getResult(); + String finalTangentResult = String.valueOf(tangentResult); + Console.println(finalTangentResult); + break; case "4": From 5cd31915b31337d9fca1a6fea8822c6b37acbbb4 Mon Sep 17 00:00:00 2001 From: jaiden Date: Sun, 12 Jul 2026 18:09:44 -0400 Subject: [PATCH 09/15] trig cases 3-6 have been glued --- .../scientificcalculator/Arithmetic.java | 22 +++++++------- .../scientificcalculator/MainApplication.java | 29 +++++++++++++++++-- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java index 8ba2971c..bdce8170 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Arithmetic.java @@ -77,19 +77,21 @@ public Arithmetic tangent() { } - // public Arithmetic cosecant(double num) { - // this.result = Math.cos(this.result); - // return this; + public Arithmetic cosecant() { + this.result = (1/(Math.sin(this.result))); + return this; - // } + } - // public Arithmetic secant(double num) { - - // } + public Arithmetic secant() { + this.result = (1/(Math.cos(this.result))); + return this; + } - // public Arithmetic cotangent(double num) { - - // } + public Arithmetic cotangent() { + this.result = (1/(Math.tan(this.result))); + return this; + } diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 6ff2a23a..9d89bc9c 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -309,8 +309,6 @@ public static int handlePageTwo( case "2": Console.println("Cosine selected."); - double CommitTest2; - double cosineInput = Console.getDoubleInput("Enter first number"); Arithmetic cosine = new Arithmetic(cosineInput); @@ -336,14 +334,41 @@ public static int handlePageTwo( case "4": Console.println("Cosecant selected."); + + double cosecantInput = Console.getDoubleInput("Enter first number"); + Arithmetic cosecant = new Arithmetic(cosecantInput); + + cosecant.cosecant(); + double cosecantResult = cosecant.getResult(); + String finalCosecantResult = String.valueOf(cosecantResult); + Console.println(finalCosecantResult); + break; case "5": Console.println("Secant selected."); + + double secantInput = Console.getDoubleInput("Enter first number"); + Arithmetic secant = new Arithmetic(secantInput); + + secant.secant(); + double secantResult = secant.getResult(); + String finalSecantResult = String.valueOf(secantResult); + Console.println(finalSecantResult); + break; case "6": Console.println("Cotangent selected."); + + double cotangentInput = Console.getDoubleInput("Enter first number"); + Arithmetic cotangent = new Arithmetic(cotangentInput); + + cotangent.cotangent(); + double cotangentResult = cotangent.getResult(); + String finalCotangentResult = String.valueOf(cotangentResult); + Console.println(finalCotangentResult); + break; case "7": From 26ddd570e92ef8d0bcf336ce34ceb75a6731dab9 Mon Sep 17 00:00:00 2001 From: jaiden Date: Mon, 13 Jul 2026 05:54:33 -0400 Subject: [PATCH 10/15] added PageResult class --- .../com/zipcodewilmington/scientificcalculator/PageResult.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java b/src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java new file mode 100644 index 00000000..e69de29b From b0a188b5eb0e2282b482b530e7daffa42a98f5f4 Mon Sep 17 00:00:00 2001 From: jaiden Date: Mon, 13 Jul 2026 05:56:25 -0400 Subject: [PATCH 11/15] added pageresult method --- .../scientificcalculator/PageResult.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java b/src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java new file mode 100644 index 00000000..1c66b5c6 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/PageResult.java @@ -0,0 +1,20 @@ +package com.zipcodewilmington.scientificcalculator; + +public class PageResult { + private int currentPage; + private String mode; + + public PageResult(int currentPage, String mode) { + this.currentPage = currentPage; + this.mode = mode; + } + + public int getCurrentPage() { + return this.currentPage; + } + + public String getMode() { + return this.mode; + } + +} From ae9dde65166ff87f839cc141347db6be659eb929 Mon Sep 17 00:00:00 2001 From: jaiden Date: Mon, 13 Jul 2026 06:15:06 -0400 Subject: [PATCH 12/15] added Degree/Radian conversion --- .../scientificcalculator/MainApplication.java | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 9d89bc9c..6909538f 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -51,6 +51,8 @@ public static void startCalculator() { int currentPage = 1; + String mode = "RAD"; + while (calculatorRunning) { displayCurrentPage(currentPage); @@ -77,11 +79,9 @@ public static void startCalculator() { break; case 2: - currentPage = - handlePageTwo( - choice, - currentPage - ); + PageResult pageTwoResult = handlePageTwo(choice, currentPage, mode); + currentPage = pageTwoResult.getCurrentPage(); + mode = pageTwoResult.getMode(); break; @@ -286,17 +286,22 @@ public static int handlePageOne( return currentPage; } - public static int handlePageTwo( + + public static PageResult handlePageTwo( String choice, - int currentPage + int currentPage, + String mode ) { switch (choice) { - case "1": Console.println("Sine selected."); double sineInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + sineInput = Math.toRadians(sineInput); + } Arithmetic sine = new Arithmetic(sineInput); sine.sine(); @@ -310,6 +315,11 @@ public static int handlePageTwo( Console.println("Cosine selected."); double cosineInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + cosineInput = Math.toRadians(cosineInput); + } + Arithmetic cosine = new Arithmetic(cosineInput); cosine.cosine(); @@ -323,6 +333,11 @@ public static int handlePageTwo( Console.println("Tangent selected."); double tangentInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + tangentInput = Math.toRadians(tangentInput); + } + Arithmetic tangent = new Arithmetic(tangentInput); tangent.tangent(); @@ -336,6 +351,11 @@ public static int handlePageTwo( Console.println("Cosecant selected."); double cosecantInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + cosecantInput = Math.toRadians(cosecantInput); + } + Arithmetic cosecant = new Arithmetic(cosecantInput); cosecant.cosecant(); @@ -349,6 +369,11 @@ public static int handlePageTwo( Console.println("Secant selected."); double secantInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + secantInput = Math.toRadians(secantInput); + } + Arithmetic secant = new Arithmetic(secantInput); secant.secant(); @@ -362,6 +387,11 @@ public static int handlePageTwo( Console.println("Cotangent selected."); double cotangentInput = Console.getDoubleInput("Enter first number"); + + if (mode.equals("DEG")) { + cotangentInput = Math.toRadians(cotangentInput); + } + Arithmetic cotangent = new Arithmetic(cotangentInput); cotangent.cotangent(); @@ -371,12 +401,14 @@ public static int handlePageTwo( break; - case "7": + case "7": Console.println("Degrees mode selected."); + mode = "DEG"; break; case "8": Console.println("Radians mode selected."); + mode = "RAD"; break; case "C": @@ -399,7 +431,9 @@ public static int handlePageTwo( Console.println("Invalid selection."); } - return currentPage; + PageResult chosenPage = new PageResult(currentPage, mode); + + return chosenPage; } public static int handlePageThree( From fdbeb3eca42f1ef640c2bca10b713af24ac07da9 Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 13 Jul 2026 08:39:02 -0400 Subject: [PATCH 13/15] Completed calculator menus and display functionality --- .../scientificcalculator/Calculator.java | 59 ++- .../scientificcalculator/MainApplication.java | 387 +++++++++++------- ...ificCalculator-Casio-master.code-workspace | 11 + 3 files changed, 302 insertions(+), 155 deletions(-) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator-Casio-master.code-workspace diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index b60dac69..26ddbaa1 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -2,6 +2,59 @@ public class Calculator { - - -} + private double currentValue; + private double memory; + + public Calculator() { + this.currentValue = 0; + this.memory = 0; + } + + public void setCurrentValue(double currentValue) { + this.currentValue = currentValue; + } + + public double getCurrentValue() { + return currentValue; + } + + public void memoryStore() { + memory = currentValue; + } + + public double memoryRecall() { + currentValue = memory; + return currentValue; + } + + public void memoryAdd() { + memory = memory + currentValue; + } + + public void memoryReset() { + memory = 0; + } + + public double getMemory() { + return memory; + } + + public String displayBinary() { + int wholeNumber = (int) currentValue; + return Integer.toBinaryString(wholeNumber); + } + + public String displayOctal() { + int wholeNumber = (int) currentValue; + return Integer.toOctalString(wholeNumber); + } + + public String displayDecimal() { + return String.valueOf(currentValue); + } + + public String displayHexadecimal() { + int wholeNumber = (int) currentValue; + return Integer.toHexString(wholeNumber).toUpperCase(); + } +} \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 9d89bc9c..134280db 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -10,11 +10,10 @@ public static void main(String[] args) { displayStartMenu(); - // I recommend making the choices (y/n) - String startChoice = - Console.getStringInput("Enter your choice: ") - .trim() - .toUpperCase(); + String startChoice = Console + .getStringInput("Enter your choice: ") + .trim() + .toUpperCase(); switch (startChoice) { @@ -42,33 +41,32 @@ public static void displayStartMenu() { Console.println("1. Enter Calculator"); Console.println("0. Exit"); Console.println("===================================="); - } //end displayStartMenu() - + } public static void startCalculator() { boolean calculatorRunning = true; - int currentPage = 1; + Calculator calculator = new Calculator(); + while (calculatorRunning) { displayCurrentPage(currentPage); - String choice = - Console.getStringInput("Enter selection: ") - .trim() - .toUpperCase(); + String choice = Console + .getStringInput("Enter selection: ") + .trim() + .toUpperCase(); switch (currentPage) { case 1: - currentPage = - //where did handlePageOne come from? - handlePageOne( - choice, - currentPage - ); + currentPage = handlePageOne( + choice, + currentPage, + calculator + ); if (choice.equals("B")) { calculatorRunning = false; @@ -77,29 +75,26 @@ public static void startCalculator() { break; case 2: - currentPage = - handlePageTwo( - choice, - currentPage - ); - + currentPage = handlePageTwo( + choice, + currentPage, + calculator + ); break; case 3: - currentPage = - handlePageThree( - choice, - currentPage - ); - + currentPage = handlePageThree( + choice, + currentPage + ); break; case 4: - currentPage = - handlePageFour( - choice, - currentPage - ); + currentPage = handlePageFour( + choice, + currentPage, + calculator + ); if (choice.equals("B")) { calculatorRunning = false; @@ -143,130 +138,165 @@ public static void displayCurrentPage(int currentPage) { public static int handlePageOne( String choice, - int currentPage + int currentPage, + Calculator calculator ) { switch (choice) { - /* - where do the two numbers come from?: getDoubleInput(); - how many times do I neet to call it? Once, the c - where does the artithmetic object get created? - after I call .add(); how do I get the number back out to show to the user? - */ - - case "1": + case "1": { Console.println("Addition selected."); - //Logic/// - double num1 = Console.getDoubleInput("Enter first number"); - double num2 = Console.getDoubleInput("Enter second number"); + double num1 = + Console.getDoubleInput("Enter first number: "); + + double num2 = + Console.getDoubleInput("Enter second number: "); + Arithmetic add = new Arithmetic(num1); + add.add(num2); + double result = add.getResult(); - String finalResult = String.valueOf(result); - Console.println(finalResult); - //Logic// + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "2": + case "2": { Console.println("Subtraction selected."); - //Logic/// - double snum1 = Console.getDoubleInput("Enter first number"); - double snum2 = Console.getDoubleInput("Enter second number"); - Arithmetic sub = new Arithmetic(snum1); - sub.subtract(snum2); - double subResult = sub.getResult(); - String finalSubResult = String.valueOf(subResult); - Console.println(finalSubResult); - //Logic// + double num1 = + Console.getDoubleInput("Enter first number: "); + + double num2 = + Console.getDoubleInput("Enter second number: "); + + Arithmetic subtract = new Arithmetic(num1); + + subtract.subtract(num2); + double result = subtract.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "3": + case "3": { Console.println("Multiplication selected."); - //Logic/// - double mnum1 = Console.getDoubleInput("Enter first number"); - double mnum2 = Console.getDoubleInput("Enter second number"); - Arithmetic multiply = new Arithmetic(mnum1); - multiply.multiply(mnum2); - double mResult = multiply.getResult(); - String finalMultiplySubResult = String.valueOf(mResult); - Console.println(finalMultiplySubResult); - //Logic// + double num1 = + Console.getDoubleInput("Enter first number: "); + + double num2 = + Console.getDoubleInput("Enter second number: "); + + Arithmetic multiply = new Arithmetic(num1); + multiply.multiply(num2); + + double result = multiply.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "4": + case "4": { Console.println("Division selected."); - //Logic/// - double dnum1 = Console.getDoubleInput("Enter first number"); - double dnum2 = Console.getDoubleInput("Enter second number"); + double num1 = + Console.getDoubleInput("Enter first number: "); + + double num2 = + Console.getDoubleInput("Enter second number: "); try { - Arithmetic divide = new Arithmetic(dnum1); - divide.divide(dnum2); - double dResult = divide.getResult(); - String finalDivideResult = String.valueOf(dResult); - Console.println(finalDivideResult); - } catch (ArithmeticException e) { - // TODO: handle exception - Console.println("Invalid input. You cannot divide by 0, please try again"); + Arithmetic divide = new Arithmetic(num1); + + divide.divide(num2); + + double result = divide.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); + + } catch (ArithmeticException exception) { + + Console.println( + "Invalid input. You cannot divide by 0." + ); } - - //Logic// break; + } - case "5": + case "5": { Console.println("Square root selected."); - //Logic/// tehcnically redunant but it's functional. - double sqrtnum1 = Console.getDoubleInput("Enter first number"); - Arithmetic squareRoot = new Arithmetic(sqrtnum1); - squareRoot.squareRoot(sqrtnum1); - double sqrtResult = squareRoot.getResult(); - String finalSquareRootResult = String.valueOf(sqrtResult); - Console.println(finalSquareRootResult); - //Logic// + + double number = + Console.getDoubleInput("Enter number: "); + + Arithmetic squareRoot = new Arithmetic(number); + + squareRoot.squareRoot(number); + + double result = squareRoot.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "6": + case "6": { Console.println("Power selected."); - //Logic/// - double powernum1 = Console.getDoubleInput("Enter first number"); - double powernum2 = Console.getDoubleInput("Enter second number"); - Arithmetic power = new Arithmetic(powernum1); - power.power(powernum2); - double powerResult = power.getResult(); - String finalPowerResult = String.valueOf(powerResult); - Console.println(finalPowerResult); - //Logic// - + double base = + Console.getDoubleInput("Enter first number: "); + + double exponent = + Console.getDoubleInput("Enter second number: "); + + Arithmetic power = new Arithmetic(base); + + power.power(exponent); + + double result = power.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "7": + case "7": { Console.println("Modulo selected."); - // comment to push correctly - double numComment; + double num1 = + Console.getDoubleInput("Enter first number: "); + + double num2 = + Console.getDoubleInput("Enter second number: "); + + Arithmetic modulo = new Arithmetic(num1); - //Logic/ - double modnum1 = Console.getDoubleInput("Enter first number"); - double modnum2 = Console.getDoubleInput("Enter second number"); - Arithmetic modulo = new Arithmetic(modnum1); - modulo.modulo(modnum2); - double moduloResult = modulo.getResult(); - String finalModuloResult = String.valueOf(moduloResult); - Console.println(finalModuloResult); - //Logic// + modulo.modulo(num2); + double result = modulo.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } case "C": clearDisplay(); @@ -288,88 +318,119 @@ public static int handlePageOne( public static int handlePageTwo( String choice, - int currentPage + int currentPage, + Calculator calculator ) { switch (choice) { - case "1": + case "1": { Console.println("Sine selected."); - double sineInput = Console.getDoubleInput("Enter first number"); + double sineInput = + Console.getDoubleInput("Enter number: "); + Arithmetic sine = new Arithmetic(sineInput); sine.sine(); - double sineResult = sine.getResult(); - String finalSineResult = String.valueOf(sineResult); - Console.println(finalSineResult); + double result = sine.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "2": + case "2": { Console.println("Cosine selected."); - double cosineInput = Console.getDoubleInput("Enter first number"); + double cosineInput = + Console.getDoubleInput("Enter number: "); + Arithmetic cosine = new Arithmetic(cosineInput); cosine.cosine(); - double cosineResult = cosine.getResult(); - String finalcoSineResult = String.valueOf(cosineResult); - Console.println(finalcoSineResult); + double result = cosine.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "3": + case "3": { Console.println("Tangent selected."); - double tangentInput = Console.getDoubleInput("Enter first number"); + double tangentInput = + Console.getDoubleInput("Enter number: "); + Arithmetic tangent = new Arithmetic(tangentInput); tangent.tangent(); - double tangentResult = tangent.getResult(); - String finalTangentResult = String.valueOf(tangentResult); - Console.println(finalTangentResult); + double result = tangent.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "4": + case "4": { Console.println("Cosecant selected."); - double cosecantInput = Console.getDoubleInput("Enter first number"); + double cosecantInput = + Console.getDoubleInput("Enter number: "); + Arithmetic cosecant = new Arithmetic(cosecantInput); cosecant.cosecant(); - double cosecantResult = cosecant.getResult(); - String finalCosecantResult = String.valueOf(cosecantResult); - Console.println(finalCosecantResult); + double result = cosecant.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "5": + case "5": { Console.println("Secant selected."); - double secantInput = Console.getDoubleInput("Enter first number"); + double secantInput = + Console.getDoubleInput("Enter number: "); + Arithmetic secant = new Arithmetic(secantInput); secant.secant(); - double secantResult = secant.getResult(); - String finalSecantResult = String.valueOf(secantResult); - Console.println(finalSecantResult); + double result = secant.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } - case "6": + case "6": { Console.println("Cotangent selected."); - double cotangentInput = Console.getDoubleInput("Enter first number"); + double cotangentInput = + Console.getDoubleInput("Enter number: "); + Arithmetic cotangent = new Arithmetic(cotangentInput); cotangent.cotangent(); - double cotangentResult = cotangent.getResult(); - String finalCotangentResult = String.valueOf(cotangentResult); - Console.println(finalCotangentResult); + double result = cotangent.getResult(); + + calculator.setCurrentValue(result); + + Console.println(String.valueOf(result)); break; + } case "7": Console.println("Degrees mode selected."); @@ -466,41 +527,63 @@ public static int handlePageThree( public static int handlePageFour( String choice, - int currentPage + int currentPage, + Calculator calculator ) { switch (choice) { case "1": Console.println("Binary display selected."); + Console.println(calculator.displayBinary()); break; case "2": Console.println("Octal display selected."); + Console.println(calculator.displayOctal()); break; case "3": Console.println("Decimal display selected."); + Console.println(calculator.displayDecimal()); break; case "4": Console.println("Hexadecimal display selected."); + Console.println(calculator.displayHexadecimal()); break; case "5": - Console.println("Memory store selected."); + calculator.memoryStore(); + + Console.println( + "Stored in memory: " + + calculator.getMemory() + ); break; case "6": - Console.println("Memory recall selected."); + Console.println( + "Memory recalled: " + + calculator.memoryRecall() + ); break; case "7": - Console.println("Memory add selected."); + calculator.memoryAdd(); + + Console.println( + "Current value added to memory." + ); + + Console.println( + "Memory: " + calculator.getMemory() + ); break; case "8": - Console.println("Memory reset selected."); + calculator.memoryReset(); + Console.println("Memory reset to 0."); break; case "C": diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator-Casio-master.code-workspace b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator-Casio-master.code-workspace new file mode 100644 index 00000000..c7380b5d --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificCalculator-Casio-master.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "../../../../../../../../../Downloads/ScientificCalculator-Casio-master" + }, + { + "path": "../../../../../.." + } + ], + "settings": {} +} \ No newline at end of file From 4f362f1200d9afc0de7467c4accb3677d2ee267c Mon Sep 17 00:00:00 2001 From: jaiden Date: Mon, 13 Jul 2026 12:27:20 -0400 Subject: [PATCH 14/15] added secret feature again --- .../scientificcalculator/MainApplication.java | 80 ++++++++++++++----- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index f8425ab0..35be59f3 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -1,5 +1,10 @@ + + package com.zipcodewilmington.scientificcalculator; +import java.net.URI; +import java.awt.Desktop; + public class MainApplication { public static void main(String[] args) { @@ -167,6 +172,10 @@ public static int handlePageOne( double result = add.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -188,6 +197,10 @@ public static int handlePageOne( double result = subtract.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -209,6 +222,10 @@ public static int handlePageOne( double result = multiply.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -232,6 +249,10 @@ public static int handlePageOne( double result = divide.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -258,6 +279,10 @@ public static int handlePageOne( double result = squareRoot.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -279,6 +304,10 @@ public static int handlePageOne( double result = power.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -300,6 +329,10 @@ public static int handlePageOne( double result = modulo.getResult(); + if (result == 67) { + secretFeature1(); + } + calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -345,11 +378,11 @@ public static PageResult handlePageTwo( sine.sine(); - double result = sine.getResult(); + double sineresult = sine.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(sineresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(sineresult)); break; case "2": { @@ -365,11 +398,11 @@ public static PageResult handlePageTwo( cosine.cosine(); - double result = cosine.getResult(); + double cosineresult = cosine.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(cosineresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(cosineresult)); break; } @@ -386,11 +419,11 @@ public static PageResult handlePageTwo( tangent.tangent(); - double result = tangent.getResult(); + double tangentresult = tangent.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(tangentresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(tangentresult)); break; } @@ -407,11 +440,11 @@ public static PageResult handlePageTwo( cosecant.cosecant(); - double result = cosecant.getResult(); + double cosecantresult = cosecant.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(cosecantresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(cosecantresult)); break; } @@ -428,11 +461,11 @@ public static PageResult handlePageTwo( secant.secant(); - double result = secant.getResult(); + double secantresult = secant.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(secantresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(secantresult)); break; } @@ -449,11 +482,11 @@ public static PageResult handlePageTwo( cotangent.cotangent(); - double result = cotangent.getResult(); + double cotangentresult = cotangent.getResult(); - calculator.setCurrentValue(result); + calculator.setCurrentValue(cotangentresult); - Console.println(String.valueOf(result)); + Console.println(String.valueOf(cotangent)); break; } @@ -735,4 +768,13 @@ public static void clearDisplay() { Console.println("Display cleared."); } -} \ No newline at end of file + + public static void secretFeature1() { + try { Desktop.getDesktop().browse(new URI("https://www.tiktok.com/@notanothercomchannel/video/7548521677651528991?lang=en")); + + } catch (Exception e) { + // TODO: handle exception startCalculator(); } } +} + } + + } \ No newline at end of file From 86482ff111e796f452959d1ad13816753d985563 Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 13 Jul 2026 12:56:49 -0400 Subject: [PATCH 15/15] Added secret feature2 --- .../scientificcalculator/MainApplication.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 35be59f3..841619f1 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -2,8 +2,8 @@ package com.zipcodewilmington.scientificcalculator; -import java.net.URI; import java.awt.Desktop; +import java.net.URI; public class MainApplication { @@ -172,9 +172,11 @@ public static int handlePageOne( double result = add.getResult(); - if (result == 67) { - secretFeature1(); - } + if (result == 67) { + secretFeature1(); + } else if (result == 69) { + secretFeature2(); + } calculator.setCurrentValue(result); @@ -199,6 +201,8 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } calculator.setCurrentValue(result); @@ -224,6 +228,8 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } calculator.setCurrentValue(result); @@ -251,6 +257,8 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } calculator.setCurrentValue(result); @@ -281,8 +289,9 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } - calculator.setCurrentValue(result); Console.println(String.valueOf(result)); @@ -306,6 +315,8 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } calculator.setCurrentValue(result); @@ -331,6 +342,8 @@ public static int handlePageOne( if (result == 67) { secretFeature1(); + } else if (result == 69) { + secretFeature2(); } calculator.setCurrentValue(result); @@ -776,5 +789,12 @@ public static void secretFeature1() { // TODO: handle exception startCalculator(); } } } } - - } \ No newline at end of file + public static void secretFeature2() { + try { + Desktop.getDesktop().browse( + new URI("https://www.tiktok.com/t/ZTStHp5kp/") + ); + } catch (Exception e) { + } +} +} \ No newline at end of file