123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. simpleOp op = new simpleOp();
  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. break;
  30. case "+":
  31. //x = Console.getStringInput("Please enter first number.");
  32. y = Console.getStringInput("Please enter number.");
  33. simpleOp.add(op.currentNumber, Console.getNumber(y));
  34. break;
  35. case "-":
  36. //x = Console.getStringInput("Please enter first number.");
  37. y = Console.getStringInput("Please enter number.");
  38. simpleOp.sub(op.currentNumber, Console.getNumber(y));
  39. break;
  40. case "*":
  41. //x = Console.getStringInput("Please enter multiplicand.");
  42. y = Console.getStringInput("Please enter number.");
  43. simpleOp.mul(op.currentNumber, Console.getNumber(y));
  44. break;
  45. case "/":
  46. //x = Console.getStringInput("Please enter dividend.");
  47. y = Console.getStringInput("Please enter number.");
  48. simpleOp.div(op.currentNumber, Console.getNumber(y));
  49. break;
  50. case "square":
  51. //x = Console.getStringInput("Please enter your number.");
  52. simpleOp.squ(op.currentNumber);
  53. break;
  54. case "square root":
  55. //x = Console.getStringInput("Please enter your number.");
  56. simpleOp.sqrt(op.currentNumber);
  57. break;
  58. case "exponent":
  59. //x = Console.getStringInput("Please enter base.");
  60. y = Console.getStringInput("Please enter the exponent.");
  61. simpleOp.exp(op.currentNumber, Console.getNumber(y));
  62. break;
  63. case "inverse":
  64. //x = Console.getStringInput("Please enter your number.");
  65. simpleOp.inv(op.currentNumber);
  66. break;
  67. case "invert":
  68. simpleOp.invert(op.currentNumber);
  69. break;
  70. // default:
  71. // System.out.println("You have not provided valid input. Please enter \"?\" for a list of commands.");
  72. // break;
  73. }
  74. // //if/else state
  75. // if(opInput.equals("add") || opInput.equals("+")){
  76. // String addRequest1 = Console.getStringInput("Whats the first number you'll like to add?");
  77. // String addRequest2 = Console.getStringInput("Whats the second number you'll like to add?");
  78. // simpleOp.add(Console.getInput(addRequest1), Console.getNumber(addRequest2));
  79. // }else if(opInput.equals("invert")){
  80. // String invertRequest = Console.getStringInput("What number would you like to invert?");
  81. // simpleOp.invert(Console.getInput(invertRequest));
  82. //
  83. }
  84. }