|
@@ -29,31 +29,7 @@ class Calculator{
|
29
|
29
|
off = true;
|
30
|
30
|
System.out.println("Goodbye!!");
|
31
|
31
|
|
32
|
|
- } else if(toDo.equalsIgnoreCase("memory")){
|
33
|
|
- System.out.println("Read, Change or Clear?");
|
34
|
|
- String mem = input1.next();
|
35
|
|
- switch(mem) {
|
36
|
|
- case "Read" :
|
37
|
|
- result = Memory.memRead();
|
38
|
|
- Memory.printAns(String.valueOf(result));
|
39
|
|
- break;
|
40
|
|
-
|
41
|
|
- case "Change" :
|
42
|
|
- System.out.println("Enter number:");
|
43
|
|
- num1 = input1.nextDouble();
|
44
|
|
- result = Memory.memUpdate(num1);
|
45
|
|
- Memory.printAns(String.valueOf(result));
|
46
|
|
- break;
|
47
|
|
-
|
48
|
|
- case "Clear" :
|
49
|
|
- result = Memory.memClear();
|
50
|
|
- Memory.printAns(String.valueOf(result));
|
51
|
|
- break;
|
52
|
|
-
|
53
|
|
- }
|
54
|
|
- }
|
55
|
|
-
|
56
|
|
-
|
|
32
|
+ }
|
57
|
33
|
else {
|
58
|
34
|
|
59
|
35
|
//System.out.println("toDO is: " + toDo);
|
|
@@ -177,101 +153,26 @@ class Calculator{
|
177
|
153
|
calc.printAns(String.valueOf(result));
|
178
|
154
|
break;
|
179
|
155
|
|
|
156
|
+ case "MR" :
|
|
157
|
+ result = Memory.memRead();
|
|
158
|
+ Memory.printAns(String.valueOf(result));
|
|
159
|
+ break;
|
|
160
|
+
|
|
161
|
+ case "M+" :
|
|
162
|
+ System.out.println("Enter number:");
|
|
163
|
+ num1 = input1.nextDouble();
|
|
164
|
+ result = Memory.memUpdate(num1);
|
|
165
|
+ Memory.printAns(String.valueOf(result));
|
|
166
|
+ break;
|
|
167
|
+
|
|
168
|
+ case "MC" :
|
|
169
|
+ result = Memory.memClear();
|
|
170
|
+ Memory.printAns(String.valueOf(result));
|
|
171
|
+ break;
|
|
172
|
+
|
|
173
|
+
|
180
|
174
|
}
|
181
|
175
|
}
|
182
|
176
|
}
|
183
|
177
|
}
|
184
|
178
|
}
|
185
|
|
-
|
186
|
|
-// /**
|
187
|
|
-// * Created by leon on 2/9/18.
|
188
|
|
-// */
|
189
|
|
-// public class Console {
|
190
|
|
-// Calculator calc = new Calculator();
|
191
|
|
-
|
192
|
|
-// public static void print(String output, Object... args) {
|
193
|
|
-// System.out.printf(output, args);
|
194
|
|
-// }
|
195
|
|
-
|
196
|
|
-// public static void println(String output, Object... args) {
|
197
|
|
-// print(output + "\n", args);
|
198
|
|
-// }
|
199
|
|
-
|
200
|
|
-// public static String getMethod() {
|
201
|
|
-// Scanner scanner = new Scanner(System.in);
|
202
|
|
-// String userInput = scanner.nextLine();
|
203
|
|
-// return userInput;
|
204
|
|
-// }
|
205
|
|
-
|
206
|
|
-// public static String switchStatment() {
|
207
|
|
-// Scanner scanner = new Scanner(System.in);
|
208
|
|
-// String ultimateAnswer = "";
|
209
|
|
-// Boolean turnOff = false;
|
210
|
|
-
|
211
|
|
-// switch (getMethod()) {
|
212
|
|
-// case "add" :
|
213
|
|
-// System.out.println("Enter your numbers:");
|
214
|
|
-// double userInput = scanner.nextDouble();
|
215
|
|
-// double nextInput = scanner.nextDouble();
|
216
|
|
-
|
217
|
|
-// double answer = Calculator.add(userInput, nextInput);
|
218
|
|
-// ultimateAnswer = Double.toString(answer);
|
219
|
|
-// return Double.toString(answer);
|
220
|
|
-
|
221
|
|
-// case "subtract" :
|
222
|
|
-// System.out.println("Enter your numbers:");
|
223
|
|
-// userInput = scanner.nextDouble();
|
224
|
|
-// nextInput = scanner.nextDouble();
|
225
|
|
-
|
226
|
|
-// answer = Calculator.subtract(userInput, nextInput);
|
227
|
|
-// ultimateAnswer = Double.toString(answer);
|
228
|
|
-// return ultimateAnswer;
|
229
|
|
-
|
230
|
|
-// case "multiply" :
|
231
|
|
-// System.out.println("Enter your numbers:");
|
232
|
|
-// userInput = scanner.nextDouble();
|
233
|
|
-// nextInput = scanner.nextDouble();
|
234
|
|
-
|
235
|
|
-// answer = Calculator.multiply(userInput, nextInput);
|
236
|
|
-// ultimateAnswer = Double.toString(answer);
|
237
|
|
-// return ultimateAnswer;
|
238
|
|
-
|
239
|
|
-// case "divide" :
|
240
|
|
-// System.out.println("Enter your numbers:");
|
241
|
|
-// userInput = scanner.nextDouble();
|
242
|
|
-// nextInput = scanner.nextDouble();
|
243
|
|
-
|
244
|
|
-// answer = Calculator.divide(userInput, nextInput);
|
245
|
|
-// ultimateAnswer = Double.toString(answer);
|
246
|
|
-// return ultimateAnswer;
|
247
|
|
-
|
248
|
|
-// case "Square Root" :
|
249
|
|
-
|
250
|
|
-// }
|
251
|
|
-// return ultimateAnswer;
|
252
|
|
-// }
|
253
|
|
-
|
254
|
|
-// /*public static String getStringInput(String prompt) {
|
255
|
|
-// Scanner scanner = new Scanner(System.in);
|
256
|
|
-// println(prompt);
|
257
|
|
-// String userInput = scanner.nextLine();
|
258
|
|
-// return userInput;
|
259
|
|
-// }
|
260
|
|
-
|
261
|
|
-// public static Integer getIntegerInput(String prompt) {
|
262
|
|
-// Scanner scanner = new Scanner(System.in);
|
263
|
|
-// println(prompt);
|
264
|
|
-// int userInput = scanner.nextInt();
|
265
|
|
-// return null;
|
266
|
|
-// }
|
267
|
|
-
|
268
|
|
-// public static Double getDoubleInput(String prompt) {
|
269
|
|
-// Scanner scanner = new Scanner(System.in);
|
270
|
|
-// println(prompt);
|
271
|
|
-// double userInput = scanner.nextDouble();
|
272
|
|
-// double nextInput = scanner.nextDouble();
|
273
|
|
-// double answer = Calculator.add(userInput, nextInput);
|
274
|
|
-// return answer;
|
275
|
|
-// }*/
|
276
|
|
-
|
277
|
|
-// }
|