SciCalc.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * 4.2 Scientific Calculator Group Project
  3. * Trinh Tong, Lauren Green, Michelle Dimarino
  4. * Advanced Calculator Menu
  5. *
  6. * TO DO
  7. *
  8. * Add MainMenu class - displays mainmenu / calls back to main menu
  9. */
  10. public class SciCalc
  11. {
  12. private double memory = 0;
  13. /**
  14. * Switch Display Mode method
  15. * -> binary, octal, decimal, hexadecimal
  16. * switchDisplayMode() rotates through the options
  17. * switchDisplayMode(String mode) sets the display to the mode given
  18. */
  19. public void switchDisplay(String mode)
  20. {
  21. int baseInput = Console.getIntegerInput("Enter an integer to see the base conversions.");
  22. Console.println("Display Options"
  23. + "\nBinary: " + null
  24. + "\nOctal: " + null
  25. + "\nDecimal: " + null
  26. + "\nHexadecimal: " + null
  27. + "\n");
  28. mode = Console.getStringInput("Enter the base option to display.");
  29. if (mode.toLowerCase().equals("binary") == true) {
  30. } else if (mode.toLowerCase().equals("octal") == true) {
  31. }
  32. }
  33. /**
  34. * Converts the user input into octal and returns a string of that octal.
  35. */
  36. public String toOctal(int userInput) {
  37. return Integer.toOctalString(userInput);
  38. }
  39. /**
  40. * Store 1 numeric value in memory for recall later
  41. * M+ = add currently displayed value to the value in memorie (default = 0)
  42. * MC = reset memory
  43. * MRC = recall current valie from memory to display
  44. */
  45. public void memory()
  46. {
  47. // Memory menu
  48. Console.println("Memory Mode");
  49. // Ask for input of a number
  50. double memoryInput = Console.getDoubleInput("Enter a number to store. ");
  51. // Display memory keys
  52. Console.println("Memory Options: "
  53. + "\nM+ : adds input to memory"
  54. + "\nMC : clears current memory"
  55. + "\nMRC : displays current memory input");
  56. String memorySelect = Console.getStringInput("What would you like to do? (Enter the key)");
  57. if (memorySelect.equals("M+") == true) {
  58. // M+
  59. memory = memoryInput;
  60. } else if (memorySelect.equals("MC") == true) {
  61. // MC
  62. memory = 0;
  63. } else if (memorySelect.equals("MCR") == true) {
  64. // MCR
  65. Console.println(Double.toString(memory));
  66. }
  67. }
  68. /**
  69. * To Trig -
  70. * sends user to trig functions of the calculator
  71. */
  72. public void toTrig(int y)
  73. {
  74. // calls the trig menu
  75. Trig trigMenu = new Trig();
  76. }
  77. }