Saturday, July 27, 2013

java Program to Convert a Decimal Number into Binary, Octal, Hexadecimal

java Program to Convert a Decimal Number into Binary, Octal, Hexadecimal

import java.io.*;
class conversion
{
public static void main(String s[])throws IOException
{
int a;
DataInputStream ins=new DataInputStream (System.in);
System.out.println("Enter value");
a = Integer.parseInt(ins.readLine());
System.out.println("Binary:"+ Integer.toBinaryString(a));
System.out.println("Hexadecimal:" +
Integer.toHexString(a));
System.out.println("Octal:" + Integer.toOctalString(a));
}
}
Output:
java Program to Convert a Decimal Number into Binary, Octal, Hexadecimal

No comments:

Post a Comment