|
@@ -1,11 +1,10 @@
|
1
|
|
-
|
2
|
1
|
|
3
|
2
|
import java.util.Scanner;
|
4
|
|
-
|
5
|
3
|
/**
|
6
|
4
|
* Created by leon on 2/9/18.
|
7
|
5
|
*/
|
8
|
6
|
public class Console {
|
|
7
|
+ Calculator calc = new Calculator();
|
9
|
8
|
|
10
|
9
|
public static void print(String output, Object... args) {
|
11
|
10
|
System.out.printf(output, args);
|
|
@@ -15,7 +14,62 @@ public class Console {
|
15
|
14
|
print(output + "\n", args);
|
16
|
15
|
}
|
17
|
16
|
|
18
|
|
- public static String getStringInput(String prompt) {
|
|
17
|
+ public static String getMethod() {
|
|
18
|
+ Scanner scanner = new Scanner(System.in);
|
|
19
|
+ String userInput = scanner.nextLine();
|
|
20
|
+ return userInput;
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ public static String switchStatment() {
|
|
24
|
+ Scanner scanner = new Scanner(System.in);
|
|
25
|
+ String ultimateAnswer = "";
|
|
26
|
+ Boolean turnOff = false;
|
|
27
|
+ switch (getMethod()) {
|
|
28
|
+ case "add" :
|
|
29
|
+ System.out.println("Enter your numbers:");
|
|
30
|
+ double userInput = scanner.nextDouble();
|
|
31
|
+ double nextInput = scanner.nextDouble();
|
|
32
|
+
|
|
33
|
+ double answer = Calculator.add(userInput, nextInput);
|
|
34
|
+ ultimateAnswer = Double.toString(answer);
|
|
35
|
+ return ultimateAnswer;
|
|
36
|
+
|
|
37
|
+ case "subtract" :
|
|
38
|
+ System.out.println("Enter your numbers:");
|
|
39
|
+ userInput = scanner.nextDouble();
|
|
40
|
+ nextInput = scanner.nextDouble();
|
|
41
|
+
|
|
42
|
+ answer = Calculator.subtract(userInput, nextInput);
|
|
43
|
+ ultimateAnswer = Double.toString(answer);
|
|
44
|
+ return ultimateAnswer;
|
|
45
|
+
|
|
46
|
+ case "multiply" :
|
|
47
|
+ System.out.println("Enter your numbers:");
|
|
48
|
+ userInput = scanner.nextDouble();
|
|
49
|
+ nextInput = scanner.nextDouble();
|
|
50
|
+
|
|
51
|
+ answer = Calculator.multiply(userInput, nextInput);
|
|
52
|
+ ultimateAnswer = Double.toString(answer);
|
|
53
|
+ return ultimateAnswer;
|
|
54
|
+
|
|
55
|
+ case "divide" :
|
|
56
|
+ System.out.println("Enter your numbers:");
|
|
57
|
+ userInput = scanner.nextDouble();
|
|
58
|
+ nextInput = scanner.nextDouble();
|
|
59
|
+
|
|
60
|
+ answer = Calculator.divide(userInput, nextInput);
|
|
61
|
+ ultimateAnswer = Double.toString(answer);
|
|
62
|
+ return ultimateAnswer;
|
|
63
|
+
|
|
64
|
+ case "quit" :
|
|
65
|
+ return "quit";
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+ }
|
|
69
|
+ return ultimateAnswer;
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ /*public static String getStringInput(String prompt) {
|
19
|
73
|
Scanner scanner = new Scanner(System.in);
|
20
|
74
|
println(prompt);
|
21
|
75
|
String userInput = scanner.nextLine();
|
|
@@ -23,10 +77,19 @@ public class Console {
|
23
|
77
|
}
|
24
|
78
|
|
25
|
79
|
public static Integer getIntegerInput(String prompt) {
|
|
80
|
+ Scanner scanner = new Scanner(System.in);
|
|
81
|
+ println(prompt);
|
|
82
|
+ int userInput = scanner.nextInt();
|
26
|
83
|
return null;
|
27
|
84
|
}
|
28
|
85
|
|
29
|
86
|
public static Double getDoubleInput(String prompt) {
|
30
|
|
- return null;
|
31
|
|
- }
|
|
87
|
+ Scanner scanner = new Scanner(System.in);
|
|
88
|
+ println(prompt);
|
|
89
|
+ double userInput = scanner.nextDouble();
|
|
90
|
+ double nextInput = scanner.nextDouble();
|
|
91
|
+ double answer = Calculator.add(userInput, nextInput);
|
|
92
|
+ return answer;
|
|
93
|
+ }*/
|
|
94
|
+
|
32
|
95
|
}
|