opSwitch.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. +"x rooted WIP"+"\n"
  33. +"log WIP"+"\n"
  34. +"ln WIP"+"\n"
  35. +"log (CHANGE OF BASE ) WIP"+"\n"
  36. +"sin WIP"+"\n"
  37. +"cos WIP"+"\n"
  38. +"tan WIP"+"\n"
  39. +"inverse of sin WIP"+"\n"
  40. +"inver of cos WIP"+"\n"
  41. +"inverse of tan WIP"+"\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 "x rooted":
  96. break;
  97. case "log":
  98. break;
  99. case "ln":
  100. break;
  101. case "log (change of base)":
  102. break;
  103. case "sin":
  104. Trigonometry.sin(op.currentNumber);
  105. break;
  106. case "cos":
  107. Trigonometry.cos(op.currentNumber);
  108. break;
  109. case "tan":
  110. Trigonometry.tan(op.currentNumber);
  111. break;
  112. case "inverse of sin":
  113. Trigonometry.sinInverse(op.currentNumber);
  114. break;
  115. case "inverse of cos":
  116. Trigonometry.cosInverse(op.currentNumber);
  117. break;
  118. case "inverse of tan":
  119. Trigonometry.tanInverse(op.currentNumber);
  120. break;
  121. }
  122. }
  123. }