|
@@ -8,14 +8,75 @@
|
8
|
8
|
public class opSwitch
|
9
|
9
|
{
|
10
|
10
|
public static void choose(String opInput){
|
11
|
|
- //if/else state
|
12
|
|
- if(opInput.equals("add") || opInput.equals("+")){
|
13
|
|
- String addRequest1 = Console.getStringInput("Whats the first number you'll like to add?");
|
14
|
|
- String addRequest2 = Console.getStringInput("Whats the second number you'll like to add?");
|
15
|
|
- simpleOp.add(Console.getInput(addRequest1), Console.getNumber(addRequest2));
|
16
|
|
- }else if(opInput.equals("invert")){
|
17
|
|
- String invertRequest = Console.getStringInput("What number would you like to invert?");
|
18
|
|
- simpleOp.invert(Console.getInput(invertRequest));
|
|
11
|
+ String x;
|
|
12
|
+ String y;
|
|
13
|
+ // switchboard for operations
|
|
14
|
+ switch (opInput) {
|
|
15
|
+ case "?":
|
|
16
|
+ System.out.println("Commands include:\n"
|
|
17
|
+ +"+"+"\n"
|
|
18
|
+ +"-"+"\n"
|
|
19
|
+ +"*"+"\n"
|
|
20
|
+ +"/"+"\n"
|
|
21
|
+ +"square"+"\n"
|
|
22
|
+ +"square root"+"\n"
|
|
23
|
+ +"exponent"+"\n"
|
|
24
|
+ +"inverse"+"\n"
|
|
25
|
+ +"quit"+"\n"
|
|
26
|
+ +"clear"+"\n");
|
|
27
|
+ break;
|
|
28
|
+ case "+":
|
|
29
|
+ x = Console.getStringInput("Please enter first number.");
|
|
30
|
+ y = Console.getStringInput("Please enter second number.");
|
|
31
|
+ simpleOp.add(Console.getNumber(x), Console.getNumber(y));
|
|
32
|
+ break;
|
|
33
|
+ case "-":
|
|
34
|
+ x = Console.getStringInput("Please enter first number.");
|
|
35
|
+ y = Console.getStringInput("Please enter second number.");
|
|
36
|
+ simpleOp.sub(Console.getNumber(x), Console.getNumber(y));
|
|
37
|
+ break;
|
|
38
|
+ case "*":
|
|
39
|
+ x = Console.getStringInput("Please enter multiplicand.");
|
|
40
|
+ y = Console.getStringInput("Please enter multiplier.");
|
|
41
|
+ simpleOp.mul(Console.getNumber(x), Console.getNumber(y));
|
|
42
|
+ break;
|
|
43
|
+ case "/":
|
|
44
|
+ x = Console.getStringInput("Please enter dividend.");
|
|
45
|
+ y = Console.getStringInput("Please enter divisor.");
|
|
46
|
+ simpleOp.div(Console.getNumber(x), Console.getNumber(y));
|
|
47
|
+ break;
|
|
48
|
+ case "square":
|
|
49
|
+ x = Console.getStringInput("Please enter your number.");
|
|
50
|
+ simpleOp.squ(Console.getNumber(x));
|
|
51
|
+ break;
|
|
52
|
+ case "square root":
|
|
53
|
+ x = Console.getStringInput("Please enter your number.");
|
|
54
|
+ simpleOp.sqrt(Console.getNumber(x));
|
|
55
|
+ break;
|
|
56
|
+ case "exponent":
|
|
57
|
+ x = Console.getStringInput("Please enter base.");
|
|
58
|
+ y = Console.getStringInput("Please enter exponent.");
|
|
59
|
+ simpleOp.exp(Console.getNumber(x), Console.getNumber(y));
|
|
60
|
+ break;
|
|
61
|
+ case "inverse":
|
|
62
|
+ x = Console.getStringInput("Please enter your number.");
|
|
63
|
+ simpleOp.inv(Console.getNumber(x));
|
|
64
|
+ break;
|
|
65
|
+ // default:
|
|
66
|
+ // System.out.println("You have not provided valid input. Please enter \"?\" for a list of commands.");
|
|
67
|
+ // break;
|
19
|
68
|
}
|
|
69
|
+
|
|
70
|
+ // //if/else state
|
|
71
|
+ // if(opInput.equals("add") || opInput.equals("+")){
|
|
72
|
+ // String addRequest1 = Console.getStringInput("Whats the first number you'll like to add?");
|
|
73
|
+ // String addRequest2 = Console.getStringInput("Whats the second number you'll like to add?");
|
|
74
|
+ // simpleOp.add(Console.getInput(addRequest1), Console.getNumber(addRequest2));
|
|
75
|
+ // }else if(opInput.equals("invert")){
|
|
76
|
+ // String invertRequest = Console.getStringInput("What number would you like to invert?");
|
|
77
|
+ // simpleOp.invert(Console.getInput(invertRequest));
|
|
78
|
+ //
|
20
|
79
|
}
|
|
80
|
+
|
|
81
|
+
|
21
|
82
|
}
|