/** * Write a description of class Operations here. * * @author (your name) * @version (a version number or a date) */ import java.util.Scanner; public class Operations { /** * prompting a user for a command solving for that command * */ public static void printHelp(){ System.out.println("\n? | + | - | * | / |"); System.out.println("^ | sqrt | exp | inverse |"); System.out.println("cos | sine | tan | cos-1 | sin-1 | m+ | m- | MRC"); System.out.println("log | ln | ex |"); System.out.println("to clear display enter clrDisplay\n"); } public static Double runCommand() { // put your code here Scanner input = new Scanner(System.in); Double result = 0.0; //String userInput = scanner.nextLine(); scienticFunctions ScientificFunctions = new scienticFunctions(); Memory memory = new Memory(); DiplayMode displayMode = new DiplayMode(); bonusFunctions bonusFunctions = new bonusFunctions(); // Calculator calc = new .... while (true) { System.out.print("Enter a command: "); String command = input.next(); if (command.equalsIgnoreCase("exit")) { System.out.print("Thanks for calculating with us!"); break; } else if (command.equalsIgnoreCase("sine")) { if (result != 0){ result = ScientificFunctions.sine(result); } else{ result = ScientificFunctions.sine(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if (command.equalsIgnoreCase("cos")) { if (result != 0){ result = ScientificFunctions.cosine(result); } else{ result = ScientificFunctions.cosine(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if (command.equalsIgnoreCase("tan")) { if (result != 0){ result = ScientificFunctions.tangent(result); } else{ result = ScientificFunctions.tangent(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if (command.equalsIgnoreCase("cos-1")) { if (result != 0){ result = ScientificFunctions.inverseCosine(result); } else{ result = ScientificFunctions.inverseCosine(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if (command.equalsIgnoreCase("sin-1")) { if (result != 0){ result = ScientificFunctions.inverseSine(result); } else{ result = ScientificFunctions.inverseSine(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if (command.equalsIgnoreCase("tan-1")) { if (result != 0){ result = ScientificFunctions.inverseTangent(result); } else{ result = ScientificFunctions.inverseTangent(Console.getDoubleInput("Enter number")); } Console.printResult(result); } else if(command.equalsIgnoreCase("M+")){ memory.storeInMemory(result); Console.printResult(result); } else if (command.equalsIgnoreCase("M-")){ Console.printResult(memory.clearMemory()); } else if (command.equalsIgnoreCase("MRC")){ Console.printResult(memory.retrieveFromMemory()); } else if (command.equalsIgnoreCase("switchmode")){ displayMode.setResult(result); String mode = displayMode.enterMode(); //System.out.println(mode); displayMode.switchDisplayMode(mode); } else if (command.equalsIgnoreCase("log")){ Console.printResult(bonusFunctions.LogBaseTenOfAnumber(result)); } else if (command.equalsIgnoreCase("ln")){ Console.printResult(bonusFunctions.naturalLogLn(result)); } else if (command.equalsIgnoreCase("ex")){ Console.printResult(bonusFunctions.exponential(result)); } else if(command.equalsIgnoreCase("?")){ printHelp(); } else if(command.equalsIgnoreCase("clrDisplay")){ result = 0.0; } else{ Console.println("Invalid command please press ? for help"); } //firstNumber = result; // and on and on } return result; } //Add CommentCollapse  }