123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**
  2. * Write a description of class opSwitch here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class opSwitch
  8. {
  9. public static void choose(String opInput){
  10. Console op = new Console();
  11. String x;
  12. String y;
  13. // switchboard for operations
  14. switch (opInput) {
  15. case "?":
  16. System.out.println("Commands include:\n"
  17. +"+"+"\n"
  18. +"-"+"\n"
  19. +"*"+"\n"
  20. +"/"+"\n"
  21. +"square"+"\n"
  22. +"square root"+"\n"
  23. +"exponent"+"\n"
  24. +"inverse"+"\n"
  25. +"invert"+"\n"
  26. +"quit"+"\n"
  27. +"clear"+"\n"
  28. +"reset"+"\n"
  29. +"M+"+"\n"
  30. +"MC"+"\n"
  31. +"MRC"+"\n"
  32. +"nth root"+"\n"
  33. +"log WIP"+"\n"
  34. +"ln WIP"+"\n"
  35. +"log (CHANGE OF BASE ) WIP"+"\n"
  36. +"sin"+"\n"
  37. +"cos"+"\n"
  38. +"tan"+"\n"
  39. +"asin"+"\n"
  40. +"acos"+"\n"
  41. +"atan"+"\n");
  42. break;
  43. case "+":
  44. //x = Console.getStringInput("Please enter first number.");
  45. y = Console.getStringInput("Please enter number.");
  46. simpleOp.add(op.currentNumber, Console.getNumber(y));
  47. break;
  48. case "-":
  49. //x = Console.getStringInput("Please enter first number.");
  50. y = Console.getStringInput("Please enter number.");
  51. simpleOp.sub(op.currentNumber, Console.getNumber(y));
  52. break;
  53. case "*":
  54. //x = Console.getStringInput("Please enter multiplicand.");
  55. y = Console.getStringInput("Please enter number.");
  56. simpleOp.mul(op.currentNumber, Console.getNumber(y));
  57. break;
  58. case "/":
  59. //x = Console.getStringInput("Please enter dividend.");
  60. y = Console.getStringInput("Please enter number.");
  61. simpleOp.div(op.currentNumber, Console.getNumber(y));
  62. break;
  63. case "square":
  64. //x = Console.getStringInput("Please enter your number.");
  65. simpleOp.squ(op.currentNumber);
  66. break;
  67. case "square root":
  68. //x = Console.getStringInput("Please enter your number.");
  69. simpleOp.sqrt(op.currentNumber);
  70. break;
  71. case "exponent":
  72. //x = Console.getStringInput("Please enter base.");
  73. y = Console.getStringInput("Please enter the exponent.");
  74. simpleOp.exp(op.currentNumber, Console.getNumber(y));
  75. break;
  76. case "inverse":
  77. //x = Console.getStringInput("Please enter your number.");
  78. simpleOp.inv(op.currentNumber);
  79. break;
  80. case "invert":
  81. simpleOp.invert(op.currentNumber);
  82. break;
  83. // default:
  84. // System.out.println("You have not provided valid input. Please enter \"?\" for a list of commands.");
  85. // break;
  86. case "M+":
  87. Memory.addMemory(op.currentNumber);
  88. break;
  89. case "MC":
  90. Memory.resetMemory();
  91. break;
  92. case "MRC":
  93. Memory.recallMemory();
  94. break;
  95. case "nth root":
  96. y = Console.getStringInput("Please enter the value of n.");
  97. advOp.nthRoot(op.currentNumber, Console.getNumber(y));
  98. break;
  99. case "log":
  100. advOp.log(op.currentNumber);
  101. break;
  102. case "sin":
  103. Trigonometry.sin(op.currentNumber);
  104. break;
  105. case "cos":
  106. Trigonometry.cos(op.currentNumber);
  107. break;
  108. case "tan":
  109. Trigonometry.tan(op.currentNumber);
  110. break;
  111. case "asin":
  112. Trigonometry.sinInverse(op.currentNumber);
  113. break;
  114. case "acos":
  115. Trigonometry.cosInverse(op.currentNumber);
  116. break;
  117. case "atan":
  118. Trigonometry.tanInverse(op.currentNumber);
  119. break;
  120. }
  121. }
  122. }