MainApplication.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import java.util.Scanner;
  2. public class MainApplication {
  3. boolean on = false;
  4. public static String state = "basic";
  5. public static Calculations calculator = new Calculations();
  6. Console console = calculator.console;
  7. public void main(String[] args) {
  8. calculator.calculator = this;
  9. //Console.println("Welcome to my calculator!");
  10. //String s = Console.getStringInput("Enter a string");
  11. //Integer i = Console.getIntegerInput("Enter an integer");
  12. //Double d = Console.getDoubleInput("Enter a double.");
  13. //Console.println("The user input %s as a string", s);
  14. //Console.println("The user input %s as a integer", i);
  15. //Console.println("The user input %s as a d", d);
  16. }
  17. public void Run(){
  18. Scanner scanner = new Scanner(System.in);
  19. String result = "";
  20. while(this.on == true)
  21. {
  22. String userInput = scanner.nextLine();
  23. switch(state){
  24. case "basic":
  25. result = calculator.getCommand(userInput);
  26. System.out.println(result);
  27. break;
  28. case "PEMDAS":
  29. result = calculator.pemdas.calculate(userInput);
  30. System.out.println(result);
  31. break;
  32. }
  33. }
  34. }
  35. public void Power(){
  36. this.on = !this.on;
  37. this.Run();
  38. }
  39. }