|
@@ -6,10 +6,11 @@ import java.util.Scanner;
|
6
|
6
|
public class Console {
|
7
|
7
|
|
8
|
8
|
public static void main(String[] args) {
|
9
|
|
- double answer;
|
|
9
|
+
|
10
|
10
|
// Create all instances of classes to be used for this program
|
11
|
11
|
MainMenu mainMenu = new MainMenu();
|
12
|
12
|
Basic basicCalc = new Basic();
|
|
13
|
+ RealAdvanced advCalc = new RealAdvanced();
|
13
|
14
|
SciCalc scientificCalc = new SciCalc();
|
14
|
15
|
MemoryFunc memory = new MemoryFunc();
|
15
|
16
|
SwitchDisplay baseChange = new SwitchDisplay();
|
|
@@ -35,11 +36,11 @@ public class Console {
|
35
|
36
|
// Basic Calculator
|
36
|
37
|
case "1":
|
37
|
38
|
basicCalc.Basic();
|
38
|
|
-
|
|
39
|
+
|
39
|
40
|
String basicMode = Console.getStringInput("Enter the mode: ");
|
40
|
41
|
double basicInput1 = Console.getDoubleInput("Enter the first input: ");
|
41
|
42
|
double basicInput2 = Console.getDoubleInput("Enter the second input: ");
|
42
|
|
-
|
|
43
|
+
|
43
|
44
|
double basicAnswer = 0;
|
44
|
45
|
|
45
|
46
|
if (basicMode.equals("1")) {
|
|
@@ -72,10 +73,36 @@ public class Console {
|
72
|
73
|
Console.println("Invalid Input");
|
73
|
74
|
}
|
74
|
75
|
Console.println(Double.toString(basicAnswer));
|
75
|
|
-
|
|
76
|
+
|
76
|
77
|
break;
|
77
|
78
|
case "2":
|
78
|
|
- // Sends to Advanced Calculator Functions
|
|
79
|
+ advCalc.realAdvanced();
|
|
80
|
+ String mode = Console.getStringInput("Enter the mode: ");
|
|
81
|
+
|
|
82
|
+ double advInput1 = Console.getDoubleInput("Enter the first input: ");
|
|
83
|
+
|
|
84
|
+ double advAnswer = 0;
|
|
85
|
+
|
|
86
|
+ if (mode.equals("1")){
|
|
87
|
+ advAnswer = advCalc.squared(advInput1);
|
|
88
|
+
|
|
89
|
+ }else if (mode.equals("2")){
|
|
90
|
+
|
|
91
|
+ double advInput2 = Console.getDoubleInput("Enter the exponent value: ");
|
|
92
|
+ advAnswer = advCalc.exponent(advInput1,advInput2);
|
|
93
|
+
|
|
94
|
+ }else if (mode.equals("3")){
|
|
95
|
+
|
|
96
|
+ advAnswer = advCalc.inverse(advInput1);
|
|
97
|
+
|
|
98
|
+ }else if (mode.equals("4")){
|
|
99
|
+ advAnswer = advCalc.opposite(advInput1);
|
|
100
|
+
|
|
101
|
+ }else {
|
|
102
|
+ Console.println("Invalid input");
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ Console.println(Double.toString(advAnswer));
|
79
|
106
|
break;
|
80
|
107
|
|
81
|
108
|
case "3":
|
|
@@ -88,15 +115,17 @@ public class Console {
|
88
|
115
|
if (sciMenuInput.equals("1")) {
|
89
|
116
|
// Base Conversions
|
90
|
117
|
// while loop for display
|
91
|
|
- String mode = "";
|
92
|
|
- while (!mode.equals("Invalid Input")) {
|
93
|
|
- baseChange.switchDisplay();
|
94
|
|
- mode = Console.getStringInput("Enter the desired display mode: ");
|
95
|
|
- }
|
|
118
|
+ String baseMode = "";
|
|
119
|
+
|
|
120
|
+ baseChange.switchDisplay();
|
|
121
|
+ baseMode = Console.getStringInput("Enter the desired display mode: ");
|
96
|
122
|
|
97
|
123
|
int userInput = getIntegerInput("Enter the number you want to convert to selected base: ");
|
98
|
|
- baseChange.switchDisplayOutput(mode, userInput);
|
99
|
124
|
|
|
125
|
+ String baseOutput = baseChange.switchDisplayOutput(baseMode, userInput);
|
|
126
|
+ Console.println(baseOutput);
|
|
127
|
+
|
|
128
|
+ break;
|
100
|
129
|
// display mode
|
101
|
130
|
// gets mode
|
102
|
131
|
// asks for input
|
|
@@ -106,50 +135,51 @@ public class Console {
|
106
|
135
|
} else if (sciMenuInput.equals("3")) {
|
107
|
136
|
// To Trig Menu
|
108
|
137
|
trigMenu.trigFunctions();
|
109
|
|
- String mode = Console.getStringInput("Enter trignometric function by key: (ie. 1 for sin)");
|
|
138
|
+ String trigMode = Console.getStringInput("Enter trignometric function by key: (ie. 1 for sin)");
|
110
|
139
|
|
111
|
140
|
double trigInput = Console.getDoubleInput("Enter the input for the trignometric function: ");
|
112
|
|
-
|
113
|
|
- if (mode.equals("1")) {
|
114
|
|
- answer = trigMenu.calcSin(trigInput);
|
|
141
|
+ double trigAnswer = 0;
|
|
142
|
+ if (trigMode.equals("1")) {
|
|
143
|
+ trigAnswer = trigMenu.calcSin(trigInput);
|
115
|
144
|
|
116
|
145
|
//COS
|
117
|
|
- } else if (mode.equals("2")) {
|
118
|
|
- answer = trigMenu.calcCos(trigInput);
|
|
146
|
+ } else if (trigMode.equals("2")) {
|
|
147
|
+ trigAnswer = trigMenu.calcCos(trigInput);
|
119
|
148
|
|
120
|
149
|
//TAN
|
121
|
|
- } else if (mode.equals("3")) {
|
122
|
|
- answer = trigMenu.calcTan(trigInput);
|
|
150
|
+ } else if (trigMode.equals("3")) {
|
|
151
|
+ trigAnswer = trigMenu.calcTan(trigInput);
|
123
|
152
|
|
124
|
153
|
//ARCSIN
|
125
|
|
- } else if (mode.equals("4")) {
|
126
|
|
- answer = trigMenu.calcArcsin(trigInput);
|
|
154
|
+ } else if (trigMode.equals("4")) {
|
|
155
|
+ trigAnswer = trigMenu.calcArcsin(trigInput);
|
127
|
156
|
|
128
|
157
|
//ARCCOS
|
129
|
|
- } else if (mode.equals("5")) {
|
130
|
|
- answer = trigMenu.calcArccos(trigInput);
|
|
158
|
+ } else if (trigMode.equals("5")) {
|
|
159
|
+ trigAnswer = trigMenu.calcArccos(trigInput);
|
131
|
160
|
|
132
|
161
|
//ARCTAN
|
133
|
|
- } else if (mode.equals("6")) {
|
134
|
|
- answer = trigMenu.calcArctan(trigInput);
|
|
162
|
+ } else if (trigMode.equals("6")) {
|
|
163
|
+ trigAnswer = trigMenu.calcArctan(trigInput);
|
135
|
164
|
|
136
|
|
- } else if (mode.equals("7")) {
|
|
165
|
+ } else if (trigMode.equals("7")) {
|
137
|
166
|
break;
|
138
|
167
|
|
139
|
168
|
} else {
|
140
|
169
|
//Error message if input does not match options, loops back to the top so they can try again.
|
141
|
|
- answer = Double.NaN;
|
|
170
|
+ trigAnswer = Double.NaN;
|
142
|
171
|
|
143
|
172
|
}
|
144
|
173
|
|
145
|
|
- String trigAnswer = Double.toString(answer);
|
146
|
|
- Console.println(trigAnswer);
|
|
174
|
+ String trigAnswerString = Double.toString(trigAnswer);
|
|
175
|
+ Console.println(trigAnswerString);
|
147
|
176
|
|
148
|
177
|
String trigDefRad = Console.getStringInput("Do you want to convert your answer from radians to degrees?"
|
149
|
178
|
+ "\nEnter Y or N").toLowerCase();
|
150
|
179
|
|
151
|
180
|
if (trigDefRad.equals("y") ) {
|
152
|
|
- trigMenu.toDegrees(answer);
|
|
181
|
+ double convertAnswer = trigMenu.toDegrees(trigAnswer);
|
|
182
|
+ Console.println(Double.toString(convertAnswer));
|
153
|
183
|
}
|
154
|
184
|
break;
|
155
|
185
|
} else {
|