|
@@ -83,19 +83,19 @@ public class MathMethods
|
83
|
83
|
|
84
|
84
|
public static String switchDisplayMode(String mode){
|
85
|
85
|
Calculator display = new Calculator();
|
86
|
|
- //Double d = new Double(display.memory);
|
|
86
|
+
|
87
|
87
|
String answer = "";
|
88
|
88
|
switch (mode) {
|
89
|
89
|
case "binary":
|
90
|
|
- answer = "";
|
|
90
|
+ answer = "0b" + Integer.toBinaryString((int)display.memory);
|
91
|
91
|
break;
|
92
|
92
|
|
93
|
93
|
case "octal":
|
94
|
|
- answer = "";
|
|
94
|
+ answer = "octal" + Integer.toOctalString((int)display.memory);
|
95
|
95
|
break;
|
96
|
96
|
|
97
|
97
|
case "decimal":
|
98
|
|
- answer = "";
|
|
98
|
+ answer = String.valueOf(display.memory);
|
99
|
99
|
break;
|
100
|
100
|
|
101
|
101
|
case "hexadecimal":
|
|
@@ -106,30 +106,30 @@ public class MathMethods
|
106
|
106
|
return answer;
|
107
|
107
|
}
|
108
|
108
|
|
109
|
|
- // public static double switchDisplayMode(){
|
110
|
|
- // int i = 4;
|
111
|
|
- // double answer = 0;
|
112
|
|
-
|
113
|
|
- // if (i%4 == 0){
|
114
|
|
- // answer = switchDisplayMode("binary");
|
115
|
|
- // i++;
|
116
|
|
- // }
|
117
|
|
- // else if (i%4 == 1){
|
118
|
|
- // answer = switchDisplayMode("octal");
|
119
|
|
- // i++;
|
120
|
|
- // }
|
121
|
|
- // else if (i%4 == 2) {
|
122
|
|
- // answer = switchDisplayMode("hecadecimal");
|
123
|
|
- // i++;
|
124
|
|
- // } else {
|
125
|
|
- // answer = switchDisplayMode("decimal");
|
126
|
|
- // i++;
|
127
|
|
- // }
|
128
|
|
- // return answer;
|
129
|
|
- // }
|
|
109
|
+ public static String switchDisplayMode(){
|
|
110
|
+ int i = 4;
|
|
111
|
+ String answer = "";
|
|
112
|
+
|
|
113
|
+ if (i%4 == 0){
|
|
114
|
+ answer = switchDisplayMode("binary");
|
|
115
|
+ i++;
|
|
116
|
+ }
|
|
117
|
+ else if (i%4 == 1){
|
|
118
|
+ answer = switchDisplayMode("octal");
|
|
119
|
+ i++;
|
|
120
|
+ }
|
|
121
|
+ else if (i%4 == 2) {
|
|
122
|
+ answer = switchDisplayMode("hecadecimal");
|
|
123
|
+ i++;
|
|
124
|
+ } else {
|
|
125
|
+ answer = switchDisplayMode("decimal");
|
|
126
|
+ i++;
|
|
127
|
+ }
|
|
128
|
+ return answer;
|
|
129
|
+ }
|
130
|
130
|
|
131
|
131
|
public static void printAns(String printAnswer){
|
132
|
|
- System.out.println("ANSWER: " + printAnswer);
|
|
132
|
+ System.out.println("ANSWER: " + printAnswer + "\n \n");
|
133
|
133
|
|
134
|
134
|
}
|
135
|
135
|
|