IntegerPrinter.java 838B

12345678910111213141516171819202122232425262728293031323334
  1. import java.util.Scanner;
  2. public class IntegerPrinter {
  3. public static String printIntegerAsBinary(int value){
  4. String binary = Integer.toBinaryString(value);
  5. return binary;
  6. }
  7. public static String printIntegerAsOctal(int value){
  8. String octal = Integer.toOctalString(value);
  9. return octal;
  10. //return octal;
  11. }
  12. public static String printIntegerAsHexadecimal(int value){
  13. String Hexdecimal = Integer.toHexString(value);
  14. return Hexdecimal;
  15. }
  16. public static void main(String[] args){
  17. Scanner in = new Scanner(System.in);
  18. System.out.println("Please enter an interger");
  19. int i = in.nextInt();
  20. printIntegerAsBinary(i);
  21. printIntegerAsHexadecimal(i);
  22. printIntegerAsHexadecimal(i);
  23. }
  24. }