Program to Convert Decimal Number to Binary, Octal and Hexadecimal

 


import java.io.*;
class decBin

       public static void main(String ar[])   
      {
           int i;
           int o=0,n=0,hex=0;
           DataInputStream obj= new DataInputStream(System.in);

      try
      {   
         System.out.println(“Enter the value of n:”);
         n=Integer.parseInt(obj.readLine());      
       }
         catch(IOException e)
    { }

        System.out.println(“Answer is:”+(Integer.toBinaryString(n)));
        System.out.println(“Answer is:”+(Integer.toOctalString(n)));
        System.out.println(“Answer is:”+(Integer.toHexString(n)));
     }

}

 Posted by at 7:10 pm

  One Response to “Program to Convert Decimal Number to Binary, Octal and Hexadecimal”

  1. thanks for giving the great support to the students