AdvCalc.java 2.7KB

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