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