|
@@ -35,32 +35,32 @@ public class Console {
|
35
|
35
|
// Basic Calculator
|
36
|
36
|
case "1":
|
37
|
37
|
basicCalc.Basic();
|
38
|
|
-
|
39
|
|
- double basicInput1 = Console.getIntegerInput("Enter the first input: ");
|
40
|
|
-
|
|
38
|
+
|
41
|
39
|
String basicMode = Console.getStringInput("Enter the mode: ");
|
|
40
|
+ double basicInput1 = Console.getDoubleInput("Enter the first input: ");
|
|
41
|
+ double basicInput2 = Console.getDoubleInput("Enter the second input: ");
|
|
42
|
+
|
|
43
|
+ double basicAnswer = 0;
|
42
|
44
|
|
43
|
|
- double basicInput2 = Console.getIntegerInput("Enter the second input: ");
|
44
|
|
-
|
45
|
|
- if (basicMode.equals("+")) {
|
46
|
|
- basicCalc.getSum(basicInput1, basicInput2);
|
|
45
|
+ if (basicMode.equals("1")) {
|
|
46
|
+ basicAnswer = basicCalc.getSum(basicInput1, basicInput2);
|
47
|
47
|
|
48
|
48
|
//subtraction
|
49
|
|
- } else if (basicMode.equals("-")) {
|
50
|
|
- basicCalc.getDiff(basicInput1, basicInput2);
|
|
49
|
+ } else if (basicMode.equals("2")) {
|
|
50
|
+ basicAnswer = basicCalc.getDiff(basicInput1, basicInput2);
|
51
|
51
|
|
52
|
52
|
//multiplication
|
53
|
|
- } else if (basicMode.equals("*")) {
|
54
|
|
- basicCalc.getProduct(basicInput1, basicInput2);
|
|
53
|
+ } else if (basicMode.equals("3")) {
|
|
54
|
+ basicAnswer = basicCalc.getProduct(basicInput1, basicInput2);
|
55
|
55
|
|
56
|
56
|
//division
|
57
|
|
- } else if (basicMode.equals("/")) {
|
|
57
|
+ } else if (basicMode.equals("4")) {
|
58
|
58
|
//error message when trying to divide by 0.
|
59
|
59
|
if (basicInput2 == 0) {
|
60
|
60
|
Console.println("undefined");
|
61
|
61
|
//Insert return to main menu.
|
62
|
62
|
} else {
|
63
|
|
- basicCalc.getQuotient(basicInput1, basicInput2);
|
|
63
|
+ basicAnswer = basicCalc.getQuotient(basicInput1, basicInput2);
|
64
|
64
|
}
|
65
|
65
|
} else if (basicMode.equals("5")) {
|
66
|
66
|
|
|
@@ -68,10 +68,11 @@ public class Console {
|
68
|
68
|
|
69
|
69
|
} else {
|
70
|
70
|
//error if wrong input was entered
|
71
|
|
- answer = Double.NaN;
|
|
71
|
+ basicAnswer = Double.NaN;
|
72
|
72
|
Console.println("Invalid Input");
|
73
|
73
|
}
|
74
|
|
-
|
|
74
|
+ Console.println(Double.toString(basicAnswer));
|
|
75
|
+
|
75
|
76
|
break;
|
76
|
77
|
case "2":
|
77
|
78
|
// Sends to Advanced Calculator Functions
|