IntegerPrinter.java 589B

1234567891011121314151617181920212223242526
  1. /**
  2. * Write a program that reads an integer and prints it in
  3. * binary, octal, hexadecimal
  4. */
  5. public class IntegerPrinter {
  6. public String printIntegerAsBinary(int value){
  7. String binary = Integer.toBinaryString(value);
  8. return binary;
  9. }
  10. public String printIntegerAsOctal(int value){
  11. String octal = Integer.toOctalString(value);
  12. return octal;
  13. }
  14. public String printIntegerAsHexadecimal(int value){
  15. String hex = Integer.toHexString(value);
  16. return hex;
  17. }
  18. public static void main(String[] args){
  19. }
  20. }