/** * Created by leon on 2/9/18. */ public class MainApplication { private void commandCenter(){ //All the different feature objects CoreFeatures switchCoreFeatures = new CoreFeatures(); TrigFeatures switchTrigFeatures = new TrigFeatures(); ScientificFeatures switchScientificFeatures = new ScientificFeatures(); //User instructions String userInput = Console.getStringInput("Choose a symbol or code for the corresponding function: " + "\n"+ "'+' = addition \n"+ "'-' = subtraction \n" + "'*' = multiplication \n" + "'/' = division \n" + "'^' = square \n" + "'^/' = square root \n" + "'-/' = switch sign \n" + "'off' = turns calculator off \n\n"); switch(userInput){ case "+": double userInput2 = Console.getDoubleInput("Enter number to be added. "); Console.result = switchCoreFeatures.addNumbers(Console.result, userInput2); System.out.println(Console.result); break; case "-": double userInput3 = Console.getDoubleInput("Enter number to be subtracted. "); Console.result = switchCoreFeatures.subtractNumbers(Console.result, userInput3); System.out.println(Console.result); break; case "*": double userInput4 = Console.getDoubleInput("Enter number to be multiplied. "); Console.result = switchCoreFeatures.multiplyNumbers(Console.result, userInput4); System.out.println(Console.result); break; case "/": double userInput5 = Console.getDoubleInput("Enter number to be divided. "); Console.result = switchCoreFeatures.divideNumbers(Console.result, userInput5); System.out.println(Console.result); break; case "^": double userInput6 = Console.getDoubleInput("Enter number to be squared. "); Console.result = switchCoreFeatures.squareNumber(userInput6); System.out.println(Console.result); break; case "^/": double userInput7 = Console.getDoubleInput("Enter number to be squared rooted. "); Console.result = switchCoreFeatures.squareRoot(userInput7); System.out.println(Console.result); break; case "-/": double userInput8 = Console.getDoubleInput("Enter number to have its sign switched. "); Console.result = switchCoreFeatures.switchSign(userInput8); System.out.println(Console.result); break; case "/x": double userInput9 = Console.getDoubleInput("Enter number to be inversed. "); Console.result = switchCoreFeatures.inverseNumber(userInput9); System.out.println(Console.result); break; case "sin": double userInput10 = Console.getDoubleInput("Enter number to get the sine of. "); Console.result = switchTrigFeatures.sin(userInput10); System.out.println(Console.result); break; case "inverseSin": double userInput11 = Console.getDoubleInput("Inverse the sine of. "); Console.result = switchTrigFeatures.inverseSin(userInput11); System.out.println(Console.result); break; case "cos": double userInput12 = Console.getDoubleInput("Enter number to get the cosine of. "); Console.result = switchTrigFeatures.cos(userInput12); System.out.println(Console.result); break; case "inverseCos": double userInput13 = Console.getDoubleInput("Inverse the cosine of. "); Console.result = switchTrigFeatures.inverseCos(userInput13); System.out.println(Console.result); break; case "tan": double userInput14 = Console.getDoubleInput("Enter number to get the tangent of. "); Console.result = switchTrigFeatures.tan(userInput14); System.out.println(Console.result); break; case "inverseTan": double userInput15 = Console.getDoubleInput("Inverse the tangent of. "); Console.result = switchTrigFeatures.inverseTan(userInput15); System.out.println(Console.result); break; case"radians": double userInput16 = Console.getDoubleInput("Enter number to convert to radians. "); Console.result = switchTrigFeatures.radians(userInput16); System.out.println(Console.result); break; case"degrees": double userInput17 = Console.getDoubleInput("Enter number to convert to degrees. "); Console.result = switchTrigFeatures.degrees(userInput17); System.out.println(Console.result); break; case "logarithm": double userInput18 = Console.getDoubleInput("Enter number to take the logarithm of. "); Console.result = switchScientificFeatures.logarithm(userInput18); System.out.println(Console.result); break; case "clear": Console.clearCalculator = true; break; case "off": Console.calcRunning = false; break; /*case "m": Console.result = CoreFeatures.m; System.out.println("Number has been saved to 'm'"); Console.result = 0; }*/ }} public static void main(String[] args) { Console.println("Welcome to my calculator!"); MainApplication mainApplication = new MainApplication(); //String s = Console.getStringInput("Enter a string"); //Integer i = Console.getIntegerInput("Enter an integer"); //Double d = Console.getDoubleInput("Enter a double."); while (Console.calcRunning){ //some sort of commads that take user input for a number mainApplication.commandCenter(); } } }