From b39223c869941a8aa13c154f0f0e550a62ceb0d1 Mon Sep 17 00:00:00 2001 From: Myah Date: Sat, 25 Jun 2022 09:37:26 -0400 Subject: [PATCH 01/13] coded switchDisplayMode method --- .../scientificcalculator/ScientificFts.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java new file mode 100644 index 0000000..ab71dcd --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java @@ -0,0 +1,22 @@ +package com.zipcodewilmington.scientificcalculator; + +import java.text.DecimalFormat; +import java.util.Scanner; + +public class ScientificFts { + public String switchDisplayMode(int num) { + DecimalFormat df = new DecimalFormat("0.00"); + + String binary = (Integer.toBinaryString(num)); + String octal = (Integer.toOctalString(num)); + String decimal = (df.format(num)); + String hexadecimal = (Integer.toHexString(num)); + +// check for keyboard input +// cycle through methods +// to return binary, octal, decimal, hexidecimal + String res = (binary + " " + octal + " " + decimal + " " + hexadecimal); + return res; + + } +} From a477bd4a8c81e90538ddb34ee92018f4d71001b1 Mon Sep 17 00:00:00 2001 From: Myah Date: Sat, 25 Jun 2022 09:38:24 -0400 Subject: [PATCH 02/13] updated to 18 compatibility --- pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pom.xml b/pom.xml index e7cb4f6..90d03c6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,24 @@ com.zipcodewilmington scientific_calculator 1.0-SNAPSHOT + + + junit + junit + 4.13.2 + test + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + + 18 + 18 + \ No newline at end of file From e8295de1a8f1081779682be5c8cbba3644c1b1a1 Mon Sep 17 00:00:00 2001 From: Myah Date: Sat, 25 Jun 2022 16:15:54 -0400 Subject: [PATCH 03/13] modified switchDisplayMode method to work more accurately --- .../scientificcalculator/ScientificFts.java | 63 +++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java index ab71dcd..3f77bcc 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java @@ -4,19 +4,70 @@ import java.util.Scanner; public class ScientificFts { - public String switchDisplayMode(int num) { + + public static void main(String[] args) { + ScientificFts tester = new ScientificFts(); + tester.displayGreeting(); +// tester.userInput(); + String input = tester.userInput(); + + switch (input) { + case "q": + System.out.println("quitting calculator"); + break; + case "d": + tester.switchDisplayMode(33); + break; + default: + throw new IllegalStateException("Unexpected value: " + input); + } + } + public void displayGreeting() { + String greeting = "execute scientific features"; + String separator = "************************************************"; + String switchDisplay = "d: switch display mode(binary, octal, decimal, hexadecimal)\n"; + String quit = "q: quit"; + + String menu = greeting.toUpperCase() + "\n" + separator + "\n" + + switchDisplay + quit; + System.out.println(menu); + } + + public String userInput() { + Scanner sc = new Scanner(System.in); + String nextMode = sc.nextLine(); + + return nextMode; + } + + void switchDisplayMode(int num) { DecimalFormat df = new DecimalFormat("0.00"); String binary = (Integer.toBinaryString(num)); String octal = (Integer.toOctalString(num)); String decimal = (df.format(num)); String hexadecimal = (Integer.toHexString(num)); + int index = 0; + + String[] modeTitles = {"binary", "octal", "decimal", "hexadecimal"}; + String[] arr = {binary, octal, decimal, hexadecimal}; + boolean displayModeActive = true; -// check for keyboard input -// cycle through methods -// to return binary, octal, decimal, hexidecimal - String res = (binary + " " + octal + " " + decimal + " " + hexadecimal); - return res; + while (displayModeActive) { + System.out.println("cycling through display modes..."); + if (userInput().equals("dm")) { + System.out.println(modeTitles[index] + ": " + arr[index]); + index++; + if (index == arr.length) { + index = 0; + } + } + else { + displayModeActive = false; +// displayGreeting(); +// userInput(); + } + } } } From 2bda0abc262fae996f20ef6519d9f12d1a418f88 Mon Sep 17 00:00:00 2001 From: TamyahD <78810505+TamyahD@users.noreply.github.com> Date: Sat, 25 Jun 2022 17:27:48 -0400 Subject: [PATCH 04/13] Revert "Scientific feats" --- pom.xml | 18 ----- .../scientificcalculator/ScientificFts.java | 73 ------------------- 2 files changed, 91 deletions(-) delete mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java diff --git a/pom.xml b/pom.xml index 90d03c6..e7cb4f6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,24 +7,6 @@ com.zipcodewilmington scientific_calculator 1.0-SNAPSHOT - - - junit - junit - 4.13.2 - test - - - org.junit.jupiter - junit-jupiter - RELEASE - test - - - - 18 - 18 - \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java b/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java deleted file mode 100644 index 3f77bcc..0000000 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/ScientificFts.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.zipcodewilmington.scientificcalculator; - -import java.text.DecimalFormat; -import java.util.Scanner; - -public class ScientificFts { - - public static void main(String[] args) { - ScientificFts tester = new ScientificFts(); - tester.displayGreeting(); -// tester.userInput(); - String input = tester.userInput(); - - switch (input) { - case "q": - System.out.println("quitting calculator"); - break; - case "d": - tester.switchDisplayMode(33); - break; - default: - throw new IllegalStateException("Unexpected value: " + input); - } - } - public void displayGreeting() { - String greeting = "execute scientific features"; - String separator = "************************************************"; - String switchDisplay = "d: switch display mode(binary, octal, decimal, hexadecimal)\n"; - String quit = "q: quit"; - - String menu = greeting.toUpperCase() + "\n" + separator + "\n" + - switchDisplay + quit; - System.out.println(menu); - } - - public String userInput() { - Scanner sc = new Scanner(System.in); - String nextMode = sc.nextLine(); - - return nextMode; - } - - void switchDisplayMode(int num) { - DecimalFormat df = new DecimalFormat("0.00"); - - String binary = (Integer.toBinaryString(num)); - String octal = (Integer.toOctalString(num)); - String decimal = (df.format(num)); - String hexadecimal = (Integer.toHexString(num)); - int index = 0; - - String[] modeTitles = {"binary", "octal", "decimal", "hexadecimal"}; - String[] arr = {binary, octal, decimal, hexadecimal}; - boolean displayModeActive = true; - - while (displayModeActive) { - System.out.println("cycling through display modes..."); - if (userInput().equals("dm")) { - System.out.println(modeTitles[index] + ": " + arr[index]); - index++; - - if (index == arr.length) { - index = 0; - } - } - else { - displayModeActive = false; -// displayGreeting(); -// userInput(); - } - } - } -} From 92c2e036429b9b19b2f443179bb352a6b7832ee9 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 15:59:55 -0400 Subject: [PATCH 05/13] basic 6 operations in, no inputs. test case --- .../scientificcalculator/Calculator.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java 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..055123f --- /dev/null +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -0,0 +1,51 @@ +package com.zipcodewilmington.scientificcalculator; + +import java.lang.Math; + + +public class Calculator { + Double x, y, mem, result; + Console choiceString = new Console(); + // new Scanner item + // Input section + + + + // Operator Choice + // System.out.println("Choose an operator from '+' '-' '*' '/' '^sq' '^exp' '^y' '^neg 'inv'"); + + public int add(int x, int y) { + return x + y; + } + + public int subtract(int x, int y) { + return x - y; + } + + public int multiply(int x, int y) { + return x * y; + } + + public int divide(int x, int y) { + return x / y; + } + + public int sqr(int x, int y) { + y = (int) Math.pow(x,2); + return y ; // + } + + public int root(int x, int y) { + y = (int) Math.sqrt(x); + return y; + } + + public int inverse(int x, int y) { + y = (int) Math.expm1(x); + return y; + } + + + ///////////////// refer to private functions here + +} From 0dd83ec3365b1d176199ae5f17edc0764fe15a85 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 18:57:16 -0400 Subject: [PATCH 06/13] added exponent of x^y --- .../zipcodewilmington/scientificcalculator/Calculator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index 055123f..e20d6aa 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -35,6 +35,11 @@ public int sqr(int x, int y) { return y ; // } + public int sqry(int x, int y, int result) { + result = (int) Math.pow(x,y); + return result; + } + public int root(int x, int y) { y = (int) Math.sqrt(x); return y; From 7b9e0fa9f46f7cfcff38ba7e9349ba0c2c3aeee3 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 19:06:54 -0400 Subject: [PATCH 07/13] added invert sign functionality --- .../zipcodewilmington/scientificcalculator/Calculator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index e20d6aa..c3add43 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -50,6 +50,11 @@ public int inverse(int x, int y) { return y; } + public int invertSign(int x, int y) { + y = (int) x*-1 ; + return y; + } + ///////////////// refer to private functions here From 83e443155fbd07d88b80677ad2e04215a182af93 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 19:24:10 -0400 Subject: [PATCH 08/13] start implementation of activecalc Boolean, and default state var --- .../com/zipcodewilmington/scientificcalculator/Calculator.java | 3 ++- .../scientificcalculator/MainApplication.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index c3add43..03c5b7f 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -6,7 +6,8 @@ public class Calculator { Double x, y, mem, result; Console choiceString = new Console(); - // new Scanner item + // MainApplication activeCalc = new MainApplication(); + // Input section diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java index 5f42132..c459630 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/MainApplication.java @@ -4,6 +4,9 @@ * Created by leon on 2/9/18. */ public class MainApplication { + + boolean activeCalc = true; + public static void main(String[] args) { Console.println("Welcome to my calculator!"); String s = Console.getStringInput("Enter a string"); From ec511aec1e8be1415f1e10fb088b41212b8ce18d Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 19:51:33 -0400 Subject: [PATCH 09/13] added getCharAt method for switch statement functionality within calculator.java --- .../zipcodewilmington/scientificcalculator/Console.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java index 83f0e97..278b001 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java @@ -22,6 +22,13 @@ public static String getStringInput(String prompt) { return userInput; } + public static char getCharInput(String prompt) { + Scanner scanner = new Scanner(System.in); + println(prompt); + char userInput = scanner.next().charAt(0); + return userInput; + } + public static Integer getIntegerInput(String prompt) { return null; } From e362054de29877b6c936f2f472a428c6760038c2 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 22:28:01 -0400 Subject: [PATCH 10/13] all basic operators within test case --- .../scientificcalculator/Calculator.java | 94 ++++++++++++++++--- 1 file changed, 79 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index 03c5b7f..c2a3b21 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -5,54 +5,118 @@ public class Calculator { Double x, y, mem, result; - Console choiceString = new Console(); + String ans; + String choiceString = "+"; // MainApplication activeCalc = new MainApplication(); // Input section + public void Arithmetic(String[] args) { + switch (choiceString) { + // Case 1 + case "+": + // Print statement corresponding case + + // break keyword terminates the + result = add(x,y); + System.out.println("one"); + break; + // Case 2 + case "-": + // Print statement corresponding case + result = subtract(x,y); + System.out.println("two"); + break; + + // Case 3 + case "*": + // Print statement corresponding case + result = multiply(x,y); + System.out.println("three"); + break; + // Case 4 + case "/": + // Print statement corresponding case + result = divide(x,y); + System.out.println("four"); + break; + case "square": + // Print statement corresponding case + result = sqr(x,y); + System.out.println("five"); + break; + case "sqrt": + // Print statement corresponding case + result = root(x,y); + System.out.println("six"); + break; + case "1/x": + // Print statement corresponding case + result = inverse(x,y); + System.out.println("seven"); + break; + case "+/-": + // Print statement corresponding case + result = invertSign(x,y); + System.out.println("eight"); + break; + case "x^y": + // Print statement corresponding case + result = sqrY(x,y); + System.out.println("eight"); + break; + default: + + // Print statement corresponding case + System.out.println("Err, no match"); + break; + } + ans = String.format(String.valueOf(result)); + } // Operator Choice + // System.out.println("Choose an operator from '+' '-' '*' '/' '^sq' '^exp' '^y' '^neg 'inv'"); - public int add(int x, int y) { + public double add(double x, double y) { return x + y; } - public int subtract(int x, int y) { + public double subtract(double x, double y) { return x - y; } - public int multiply(int x, int y) { + public double multiply(double x, double y) { return x * y; } - public int divide(int x, int y) { + public double divide(double x, double y) { return x / y; } - public int sqr(int x, int y) { - y = (int) Math.pow(x,2); + public double sqr(double x, double y) { + y = Math.pow(x,2); return y ; // } - public int sqry(int x, int y, int result) { - result = (int) Math.pow(x,y); + public double sqrY(double x, double y) { + double result = Math.pow(x, y); return result; } - public int root(int x, int y) { - y = (int) Math.sqrt(x); + public double root(double x, double y) { + y = Math.sqrt(x); return y; } - public int inverse(int x, int y) { - y = (int) Math.expm1(x); + public double inverse(double x, double y) { + y = Math.expm1(x); return y; } - public int invertSign(int x, int y) { - y = (int) x*-1 ; + public double invertSign(double x, double y) { + y = x*-1; return y; } From 68c9d45211989df13f2f6ec61191c8f1dcd9c437 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 22:48:49 -0400 Subject: [PATCH 11/13] updated getIntegerInput, getDoubleInput, and fixed getCharInput --- .../scientificcalculator/Console.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java index 278b001..806d0d5 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Console.java @@ -29,11 +29,18 @@ public static char getCharInput(String prompt) { return userInput; } - public static Integer getIntegerInput(String prompt) { - return null; + public static int getIntegerInput(String prompt) { + Scanner scanner = new Scanner(System.in); + println(prompt); + String userInput = String.valueOf(scanner.nextInt()); + return Integer.parseInt(userInput); } - public static Double getDoubleInput(String prompt) { - return null; + public static double getDoubleInput(String prompt) { + //while (!prompt.) + Scanner scanner = new Scanner(System.in); + println(prompt); + double userInput = scanner.nextDouble(); + return userInput; } } From 0629f3d9781d46c012025712ed0baa599bf671d7 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 23:11:32 -0400 Subject: [PATCH 12/13] cleaned up operator code --- .../scientificcalculator/Calculator.java | 82 +++++++++---------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index c2a3b21..471e856 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -13,62 +13,61 @@ public class Calculator { public void Arithmetic(String[] args) { switch (choiceString) { // Case 1 - case "+": + case "+" -> { // Print statement corresponding case // break keyword terminates the - result = add(x,y); + result = add(x, y); System.out.println("one"); - break; + } // Case 2 - case "-": + case "-" -> { // Print statement corresponding case - result = subtract(x,y); + result = subtract(x, y); System.out.println("two"); - break; + } // Case 3 - case "*": + case "*" -> { // Print statement corresponding case - result = multiply(x,y); + result = multiply(x, y); System.out.println("three"); - break; + } // Case 4 - case "/": + case "/" -> { // Print statement corresponding case - result = divide(x,y); + result = divide(x, y); System.out.println("four"); - break; - case "square": + } + case "square" -> { // Print statement corresponding case - result = sqr(x,y); + result = sqr(x); System.out.println("five"); - break; - case "sqrt": + } + case "sqrt" -> { // Print statement corresponding case - result = root(x,y); + result = root(x); System.out.println("six"); - break; - case "1/x": + } + case "1/x" -> { // Print statement corresponding case - result = inverse(x,y); + result = inverse(x); System.out.println("seven"); - break; - case "+/-": + } + case "+/-" -> { // Print statement corresponding case - result = invertSign(x,y); + result = invertSign(x); System.out.println("eight"); - break; - case "x^y": + } + case "x^y" -> { // Print statement corresponding case - result = sqrY(x,y); + result = sqrY(x, y); System.out.println("eight"); - break; - default: + } + default -> // Print statement corresponding case - System.out.println("Err, no match"); - break; + System.out.println("Err, no match"); } ans = String.format(String.valueOf(result)); @@ -95,29 +94,24 @@ public double divide(double x, double y) { return x / y; } - public double sqr(double x, double y) { - y = Math.pow(x,2); - return y ; // + public double sqr(double x) { + return Math.pow(x, 2); // } public double sqrY(double x, double y) { - double result = Math.pow(x, y); - return result; + return Math.pow(x, y); } - public double root(double x, double y) { - y = Math.sqrt(x); - return y; + public double root(double x) { + return Math.sqrt(x); } - public double inverse(double x, double y) { - y = Math.expm1(x); - return y; + public double inverse(double x) { + return Math.expm1(x); } - public double invertSign(double x, double y) { - y = x*-1; - return y; + public double invertSign(double x) { + return x*-1; } From 45eb8e2fc22b593c10d16dcf6a7b65606a8cfbc2 Mon Sep 17 00:00:00 2001 From: jjheffernan Date: Sun, 26 Jun 2022 23:45:44 -0400 Subject: [PATCH 13/13] added printf support to Arithmetic object --- .../scientificcalculator/Calculator.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java index 471e856..c3a8ae0 100644 --- a/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java +++ b/src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java @@ -1,5 +1,6 @@ package com.zipcodewilmington.scientificcalculator; +import java.io.Console; import java.lang.Math; @@ -18,56 +19,55 @@ public void Arithmetic(String[] args) { // break keyword terminates the result = add(x, y); - System.out.println("one"); + System.out.printf("adding %.4f and %.4f",x,y); } // Case 2 case "-" -> { // Print statement corresponding case result = subtract(x, y); - System.out.println("two"); + System.out.printf("subtracting %.4f from %.4f gives",y,x,result); } // Case 3 case "*" -> { // Print statement corresponding case result = multiply(x, y); - System.out.println("three"); + System.out.printf("multiplying %.4f by %.4f gives",x,y,result); } // Case 4 case "/" -> { // Print statement corresponding case - result = divide(x, y); - System.out.println("four"); + result = divide(x,y); + System.out.printf("dividing %.4f by %.4f gives %.4f",x,y,result); } case "square" -> { // Print statement corresponding case result = sqr(x); - System.out.println("five"); + System.out.printf("the square of %.4f is %.4f",x,result); } case "sqrt" -> { // Print statement corresponding case result = root(x); - System.out.println("six"); + System.out.printf("the square root of %.4f is %.4f",x,result); } case "1/x" -> { // Print statement corresponding case result = inverse(x); - System.out.println("seven"); + System.out.printf("the inverse of %.4f is %.4f",x,result); } case "+/-" -> { // Print statement corresponding case result = invertSign(x); - System.out.println("eight"); + System.out.printf("reversed sign: %.4f",result); } case "x^y" -> { // Print statement corresponding case result = sqrY(x, y); - System.out.println("eight"); + System.out.printf("%.4f to the power of %.4f is %.4f",x,y,result); } default -> - // Print statement corresponding case - System.out.println("Err, no match"); + System.out.println("Err, no match"); } ans = String.format(String.valueOf(result));