123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
-
- /**
- * Created by leon on 2/9/18.
- */
-
- public class MainApplication {
- private void commandCenter(){
- //All the different feature objects
- CoreFeatures switchCoreFeatures = new CoreFeatures();
-
- //User instructions
- String userInput = Console.getStringInput("Choose a symbol for the corresponding function: " + "\n"+
- "'+' = addition \n"+
- "'-' = subtraction \n" +
- "'*' = multiplication \n" +
- "'/' = division \n" +
- "'^' = square \n" +
- "'^/' = square root \n" +
- "'-/' = invert 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 multiplied. ");
- Console.result = switchCoreFeatures.multiplyNumbers(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 be inverted. ");
- Console.result = switchCoreFeatures.invertSign(userInput8);
- System.out.println(Console.result);
- break;
-
- case "off":
- Console.calcRunning = false;
- break;
-
- }
- }
- 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();
-
- }
-
- }
- }
|