posted 14 years ago
Hi Jr....
First... to save you some grief when posting, make sure to use "code" button when posting code on the forum to make it easier to read and reply to.
I'm not 100% sure I know exactly how you want your output to look, but I have four suggestions for you to try.
1. At the beginning, you have the line "int num = 0;" for no apparent reason. It is never used in your code.
2. You have a line "c = OctalNum.charAt(0); " which I think you should change to "c = OctalNum.charAt(i); "
3. What is the "for (j=1; j < c; j++) " about? I would completely delete that from your code. It doesn't seem to serve a purpose and "c" is a char value not an int.
4. Change your output to "System.out.println(n+ " converted to binary is "+ binaryArray[n]); "
Below shows the changes I made....
My output is....
Octal to Binary Conversion
Enter the Octal Number:
0123
0 converted to binary is 000
1 converted to binary is 001
2 converted to binary is 010
3 converted to binary is 011
Do you want to enter another Octal number? Y for yes or N for No: