123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import java.util.Scanner;
  2. /**
  3. * Created by leon on 2/9/18.
  4. */
  5. public class Console {
  6. Calculator calc = new Calculator();
  7. public static void print(String output, Object... args) {
  8. System.out.printf(output, args);
  9. }
  10. public static void println(String output, Object... args) {
  11. print(output + "\n", args);
  12. }
  13. public static String getMethod() {
  14. Scanner scanner = new Scanner(System.in);
  15. String userInput = scanner.nextLine();
  16. return userInput;
  17. }
  18. public static String switchStatment() {
  19. Scanner scanner = new Scanner(System.in);
  20. String ultimateAnswer = "";
  21. Boolean turnOff = false;
  22. switch (getMethod()) {
  23. case "add" :
  24. System.out.println("Enter your numbers:");
  25. double userInput = scanner.nextDouble();
  26. double nextInput = scanner.nextDouble();
  27. double answer = Calculator.add(userInput, nextInput);
  28. ultimateAnswer = Double.toString(answer);
  29. return ultimateAnswer;
  30. case "subtract" :
  31. System.out.println("Enter your numbers:");
  32. userInput = scanner.nextDouble();
  33. nextInput = scanner.nextDouble();
  34. answer = Calculator.subtract(userInput, nextInput);
  35. ultimateAnswer = Double.toString(answer);
  36. return ultimateAnswer;
  37. case "multiply" :
  38. System.out.println("Enter your numbers:");
  39. userInput = scanner.nextDouble();
  40. nextInput = scanner.nextDouble();
  41. answer = Calculator.multiply(userInput, nextInput);
  42. ultimateAnswer = Double.toString(answer);
  43. return ultimateAnswer;
  44. case "divide" :
  45. System.out.println("Enter your numbers:");
  46. userInput = scanner.nextDouble();
  47. nextInput = scanner.nextDouble();
  48. answer = Calculator.divide(userInput, nextInput);
  49. ultimateAnswer = Double.toString(answer);
  50. return ultimateAnswer;
  51. case "quit" :
  52. return "quit";
  53. }
  54. return ultimateAnswer;
  55. }
  56. /*public static String getStringInput(String prompt) {
  57. Scanner scanner = new Scanner(System.in);
  58. println(prompt);
  59. String userInput = scanner.nextLine();
  60. return userInput;
  61. }
  62. public static Integer getIntegerInput(String prompt) {
  63. Scanner scanner = new Scanner(System.in);
  64. println(prompt);
  65. int userInput = scanner.nextInt();
  66. return null;
  67. }
  68. public static Double getDoubleInput(String prompt) {
  69. Scanner scanner = new Scanner(System.in);
  70. println(prompt);
  71. double userInput = scanner.nextDouble();
  72. double nextInput = scanner.nextDouble();
  73. double answer = Calculator.add(userInput, nextInput);
  74. return answer;
  75. }*/
  76. }