123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
-
- /**
- * 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();
-
- }
-
- }
- }
|