123456789101112131415161718192021222324252627282930313233 |
- import java.util.Scanner;
- import java.lang.Math;
-
- public class IntegerPrinter {
- int value = 0;
- public static String printIntegerAsBinary(int value){
- String binary = Integer.toBinaryString(value);
- return binary;
- }
-
- public static String printIntegerAsOctal(int value){
- String octal = Integer.toOctalString(value);
- return octal;
- }
-
- public static String printIntegerAsHexadecimal(int value){
- String hex = Integer.toHexString(value);
- return hex;
- }
-
- public static void main(String[] args){
- Scanner in = new Scanner(System.in);
- System.out.println("Please enter a number:");
- int i = in.nextInt();
-
-
- printIntegerAsBinary(i);
- printIntegerAsOctal(i);
- printIntegerAsHexadecimal(i);
- }
- }
-
|