Skip to content

Commit 0a296cf

Browse files
author
Raven G. Duran
committed
Added steps for all conversions
1 parent ae7142c commit 0a296cf

File tree

8 files changed

+58
-10
lines changed

8 files changed

+58
-10
lines changed
570 Bytes
Binary file not shown.

build/preprocessed/hello/HelloMIDlet.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
174174
} else if (command == okCommand5) {//GEN-LINE:|7-commandAction|11|111-preAction
175175
// write pre-action user code here
176176
int deci = Integer.parseInt(this.textField7.getString());
177-
getResultBox().setString("The Binary Equivalent is: \n" + Integer.toBinaryString(deci) );
177+
int a = deci;
178+
179+
String step = "form: decimal = 2(decimal/2) + remainder\n\nSteps:\n\n";
180+
while (a != 0){
181+
step += a + " = 2(" + (int)(a/2) + ") + " + (a%2) + "\n";
182+
a /= 2;
183+
}
184+
185+
getResultBox().setString(step + "\n\nThe Binary Equivalent is: \n" + Integer.toBinaryString(deci) );
178186
switchDisplayable(getResultBox(), getDeciToBinary());//GEN-LINE:|7-commandAction|12|111-postAction
179187
// write post-action user code here
180188
}//GEN-BEGIN:|7-commandAction|13|143-preAction
@@ -190,7 +198,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
190198
} else if (command == okCommand6) {//GEN-LINE:|7-commandAction|17|146-preAction
191199
// write pre-action user code here
192200
int deci = Integer.parseInt(this.textField9.getString());
193-
getResultBox().setString("The Hexadecimal Equivalent is: \n" + Integer.toHexString(deci) );
201+
int a = deci;
202+
203+
String step = "form: decimal = 16(decimal/16) + remainder\n\nSteps:\n\n";
204+
while (a != 0){
205+
step += a + " = 16(" + (int)(a/16) + ") + " + Integer.toHexString((int)a%16) + "\n";
206+
a /= 16;
207+
}
208+
209+
getResultBox().setString(step + "\n\nThe Hexadecimal Equivalent is: \n" + Integer.toHexString(deci) );
194210
switchDisplayable(getResultBox(), getDeciToHexa());//GEN-LINE:|7-commandAction|18|146-postAction
195211
// write post-action user code here
196212
}//GEN-BEGIN:|7-commandAction|19|134-preAction
@@ -206,7 +222,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
206222
} else if (command == okCommand) {//GEN-LINE:|7-commandAction|23|136-preAction
207223
// write pre-action user code here
208224
int deci = Integer.parseInt(this.textField8.getString());
209-
getResultBox().setString("The Octadecimal Equivalent is: \n" + Integer.toOctalString(deci) );
225+
int a = deci;
226+
227+
String step = "form: decimal = 8(decimal/8) + remainder\n\nSteps:\n\n";
228+
while (a != 0){
229+
step += a + " = 8(" + (int)(a/8) + ") + " + (a%8) + "\n";
230+
a /= 8;
231+
}
232+
233+
getResultBox().setString(step + "\n\nThe Octadecimal Equivalent is: \n" + Integer.toOctalString(deci) );
210234
switchDisplayable(getResultBox(), getDeciToOcta());//GEN-LINE:|7-commandAction|24|136-postAction
211235
// write post-action user code here
212236
}//GEN-BEGIN:|7-commandAction|25|82-preAction
690 Bytes
Binary file not shown.
570 Bytes
Binary file not shown.

dist/Discrete_Math.jad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIDlet-1: HelloMIDlet,,hello.HelloMIDlet
22
MIDlet-Description: Discrete Math Helper and Calculator
3-
MIDlet-Jar-Size: 100938
3+
MIDlet-Jar-Size: 101230
44
MIDlet-Jar-URL: Discrete_Math.jar
55
MIDlet-Name: Discrete Math Operations
66
MIDlet-Vendor: Raven G. Duran

dist/Discrete_Math.jar

292 Bytes
Binary file not shown.

nbproject/private/private.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#Thu, 27 Sep 2012 14:27:33 +0800
1+
#Thu, 27 Sep 2012 14:49:43 +0800
22
app-version.autoincrement=true
33
config.active=
4-
deployment.counter=18
5-
deployment.number=0.0.17
4+
deployment.counter=22
5+
deployment.number=0.0.21
66
file.reference.Discrete_Math-resources=C\:\\Users\\MDF\\Documents\\NetBeansProjects\\Discrete Math\\Discrete_Math-resources
77
javadoc.preview=true
88
netbeans.user=C\:\\Users\\MDF\\.netbeans\\7.1.2

src/hello/HelloMIDlet.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
174174
} else if (command == okCommand5) {//GEN-LINE:|7-commandAction|11|111-preAction
175175
// write pre-action user code here
176176
int deci = Integer.parseInt(this.textField7.getString());
177-
getResultBox().setString("The Binary Equivalent is: \n" + Integer.toBinaryString(deci) );
177+
int a = deci;
178+
179+
String step = "form: decimal = 2(decimal/2) + remainder\n\nSteps:\n\n";
180+
while (a != 0){
181+
step += a + " = 2(" + (int)(a/2) + ") + " + (a%2) + "\n";
182+
a /= 2;
183+
}
184+
185+
getResultBox().setString(step + "\n\nThe Binary Equivalent is: \n" + Integer.toBinaryString(deci) );
178186
switchDisplayable(getResultBox(), getDeciToBinary());//GEN-LINE:|7-commandAction|12|111-postAction
179187
// write post-action user code here
180188
}//GEN-BEGIN:|7-commandAction|13|143-preAction
@@ -190,7 +198,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
190198
} else if (command == okCommand6) {//GEN-LINE:|7-commandAction|17|146-preAction
191199
// write pre-action user code here
192200
int deci = Integer.parseInt(this.textField9.getString());
193-
getResultBox().setString("The Hexadecimal Equivalent is: \n" + Integer.toHexString(deci) );
201+
int a = deci;
202+
203+
String step = "form: decimal = 16(decimal/16) + remainder\n\nSteps:\n\n";
204+
while (a != 0){
205+
step += a + " = 16(" + (int)(a/16) + ") + " + Integer.toHexString((int)a%16) + "\n";
206+
a /= 16;
207+
}
208+
209+
getResultBox().setString(step + "\n\nThe Hexadecimal Equivalent is: \n" + Integer.toHexString(deci) );
194210
switchDisplayable(getResultBox(), getDeciToHexa());//GEN-LINE:|7-commandAction|18|146-postAction
195211
// write post-action user code here
196212
}//GEN-BEGIN:|7-commandAction|19|134-preAction
@@ -206,7 +222,15 @@ public void commandAction(Command command, Displayable displayable) {//GEN-END:|
206222
} else if (command == okCommand) {//GEN-LINE:|7-commandAction|23|136-preAction
207223
// write pre-action user code here
208224
int deci = Integer.parseInt(this.textField8.getString());
209-
getResultBox().setString("The Octadecimal Equivalent is: \n" + Integer.toOctalString(deci) );
225+
int a = deci;
226+
227+
String step = "form: decimal = 8(decimal/8) + remainder\n\nSteps:\n\n";
228+
while (a != 0){
229+
step += a + " = 8(" + (int)(a/8) + ") + " + (a%8) + "\n";
230+
a /= 8;
231+
}
232+
233+
getResultBox().setString(step + "\n\nThe Octadecimal Equivalent is: \n" + Integer.toOctalString(deci) );
210234
switchDisplayable(getResultBox(), getDeciToOcta());//GEN-LINE:|7-commandAction|24|136-postAction
211235
// write post-action user code here
212236
}//GEN-BEGIN:|7-commandAction|25|82-preAction

0 commit comments

Comments
 (0)