MainApplication.java 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Created by leon on 2/9/18.
  3. */
  4. public class MainApplication {
  5. public static void main(String[] args) {
  6. Console console = new Console();
  7. CoreFeatures core = new CoreFeatures(console);
  8. ScientificFeatures science = new ScientificFeatures(console);
  9. BonusFeatures bonus = new BonusFeatures(console);
  10. CustomFeatures custom = new CustomFeatures(console);
  11. String onOff = "on";
  12. console.clearCurrentValue();
  13. System.out.printf("Welcome To The Calculator! \n" +
  14. ("Current Value Is: " + console.getCurrentValue() + "\n")) ;
  15. while(onOff == "on"){
  16. switch(console.getStringInput("What would you like to do? Enter 'HELP' for options. \n")){
  17. case "getvalue": console.getCurrentValue();
  18. break;
  19. case "clear": console.clearCurrentValue();
  20. break;
  21. case "changevalue":
  22. console.changeCurrentValue(console.getDoubleInput("What Would You Like To Change Current Value To? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  23. break;
  24. case "add":
  25. core.add(console.getDoubleInput("What Would You Like To Add to Current Value? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  26. //core.add(console.getDoubleInput("What Would You Like To Add to Current Value? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n")));
  27. break;
  28. case "subtract":
  29. core.subtract(console.getDoubleInput("What Would You Like To Subtract from Current Value? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  30. break;
  31. case "multiply":
  32. core.multiply(console.getDoubleInput("What Would You Like To Multiply Current Value By? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  33. break;
  34. case "divide":
  35. core.divide(console.getDoubleInput("What Would You Like To Divide Current Value By? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  36. break;
  37. case "square": core.square();
  38. break;
  39. case "sqrt" : core.squareRoot();
  40. break;
  41. case "inverse": core.inverse();
  42. break;
  43. case "invert": core.changeSign();
  44. break;
  45. case "variableex" : core.variableExponentiation(console.getDoubleInput
  46. ("What Power Should Current Value Be Raised To? \n" + "All Inputs Should Be In Base 10/ Decimal Format \n"));
  47. break;
  48. case "switchdisplaymode": science.switchDisplayMode
  49. (console.getStringInput("Which Mode Would You Like To Enter: Binary, Octal, Decimal, or Hexadecimal"));
  50. break;
  51. case "switchunitsmode": science.switchUnitsMode
  52. (console.getStringInput("Which Trig Units Would You Like: Degrees or Radians?"));
  53. break;
  54. case "m+": console.mPlus(console.getCurrentValue());
  55. break;
  56. case "mc": console.mClear();
  57. break;
  58. case "mrc": console.mRc();
  59. break;
  60. case "sine": science.sine(console.getCurrentValue());
  61. break;
  62. case "cosine": science.cosine(console.getCurrentValue());
  63. break;
  64. case "tangent": science.tangent(console.getCurrentValue());
  65. break;
  66. case "inversesine": science.invSine(console.getCurrentValue());
  67. break;
  68. case "inversecosine": science.invCosine(console.getCurrentValue());
  69. break;
  70. case "inversetangent": science.invTangent(console.getCurrentValue());
  71. break;
  72. case "factorial": bonus.factorialOf(console.currentValue);
  73. break;
  74. case "log": bonus.logarithm(console.getCurrentValue());
  75. break;
  76. case "inverselog": bonus.invLogarithm(console.getCurrentValue());
  77. break;
  78. case "ln": bonus.lnLogarithm(console.getCurrentValue());
  79. break;
  80. case "inverseln": bonus.expLogarithm(console.getCurrentValue());
  81. break;
  82. case "addfive": custom.addFive();
  83. break;
  84. case "help": console.println(custom.helpMe());
  85. break;
  86. case "exit": onOff = "off";
  87. break;
  88. default : console.println("Invalid choice please try again");
  89. break;
  90. }
  91. console.println("Current Mode Is: " + science.displayMode);
  92. console.println("Current Trig Units are: " + science.trigOptions);
  93. if(console.getCurrentValue() != Double.POSITIVE_INFINITY){
  94. if(console.getCurrentValue() != Double.NEGATIVE_INFINITY){
  95. if (science.Mode == 2){
  96. console.println("Current Value Is: " + Long.toBinaryString(Double.doubleToRawLongBits(console.getCurrentValue())));
  97. } else if( science.Mode == 8) {
  98. console.println("Current Value Is: " + Long.toOctalString(Double.doubleToRawLongBits(console.getCurrentValue())));
  99. }
  100. else if( science.Mode == 16) {
  101. console.println("Current Value Is: " + Double.toHexString(console.getCurrentValue()));
  102. } else {
  103. console.println("Current Value Is: " + Double.toString(console.getCurrentValue()));}
  104. }else {console.println("ERR Please CLEAR To Continue!");}
  105. }else {console.println("ERR Please CLEAR To Continue!");}
  106. }
  107. }
  108. }