12345678910111213141516171819202122232425262728293031323334353637 |
-
- import java.lang.StringBuilder;
- import java.lang.*;
- //import java.lang.Integer.toOctalString();
- //import java.lang.Integer.toHexString();
- public class IntegerPrinter {
-
- public String printIntegerAsBinary(int value){
- StringBuilder build = new StringBuilder();
- while(value != 0)
- {
- build.insert(0,value % 2);
-
- value = value / 2;
- }
- return build.toString();
- }
-
- public String printIntegerAsOctal(int value){
- StringBuilder build = new StringBuilder();
- String newString = Integer.toOctalString(value);
- return newString;
-
- }
-
- public String printIntegerAsHexadecimal(int value){
- StringBuilder build = new StringBuilder();
- String newString = Integer.toHexString(value);
- return newString;
-
- }
-
- public static void main(String[] args){
-
- }
- }
|