Sunday 9 February 2014

Decimal to Hexadecimal Converter in Java

CONVERT DECIMAL INTEGER TO HEXADECIMAL 

NUMBER EXAMPLE


import java.io.*;
import java.lang.*;

public class DecimalToHexadecimal{
  public static void main(String[] args) throws IOException{  
  BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Enter the decimal value:");
  String hex = bf.readLine();
  int i = Integer.parseInt(hex);
  String hex1 = Integer.toHexString(i);
  System.out.println("Hexa decimal: " + hex1);
  }
}


run:
Enter the decimal value:
16
Hexa decimal: 10

1 comment: