import java.util.ArrayList; public class Calculations { public static Console console = new Console(); public static ArrayList library = new ArrayList(); public Calculations(){ library.add("multiply"); library.add("divide"); library.add("subtract"); library.add("add"); library.add("COS"); library.add("SIN"); library.add("TAN"); library.add("invertS"); library.add("invertN"); library.add("factorial"); library.add("switchunit"); library.add("clear"); library.add("storeM"); library.add("resetM"); library.add("recallM"); library.add("displayM"); } public static void getCommand(String userInput) { boolean foundCommand = false; String command = ""; String result = ""; String[] inputArr = userInput.split(" "); for(int i = 0; i < library.size(); i ++) { String currCommand = library.get(i); if(currCommand.equalsIgnoreCase(inputArr[0])) { command = currCommand; foundCommand = true; break; } } switch(command) { case "multiply": result = Multiply(userInput); break; case "divide": result = Divide(userInput); break; case "add": result = Add(userInput); break; case "subtract": result = Subtract(userInput); break; case "invertS": result = InvertSign(userInput); break; case "invertN": result = InvertNumber(userInput); break; case "clear": Clear(); break; } System.out.println(result); //return result; } public static ArrayList getNumbers(String userInput){ ArrayList results = new ArrayList(); //takes in a string //finds the first occurence of a number //store it as a double ( left ) //add this to the arraylist //find the second occurence of a number //store it as a double (right) //add this to the array list //if the size of the arraylist is 2 //return the array list //else return null return results; } public static String Multiply(String userInput) { //perform the operation //convert to string //return string return null; } public static String Divide(String userInput) { //perform the operation //convert to string //return string return null; } public static String Add(String userInput) { //perform the operation //convert to string //return string return null; } public static String Subtract(String userInput) { //perform the operation //convert to string //return string return null; } public static String InvertSign(String userInput) { //perform the operation //convert to string //return string return null; } public static String InvertNumber(String userInput) { //perform the operation //convert to string //return string return null; } public static void Clear() { //reset the default value to 0 } }