Find us on Google+ Kill the code: Decimal to Hexadecimal convertor (10to16 convertor)using JAVA

Monday, 26 March 2012

Decimal to Hexadecimal convertor (10to16 convertor)using JAVA

 
class extra
{
 public static void main(String args[])
 {
  hexadecimal h=new hexadecimal();
  int a1,a2=0;
  char c;
  a1=Integer.parseInt(args[0]);
  //System.out.println(h.hax(a1,a2));
  h.hax(a1);
 }
}


class hexadecimal
{
 void hax(int a1)
 {
  int b;
  char c;
  b=a1%16;
  a1=a1/16;
  if(a1>16)
  {
   hax(a1); 
  }
  System.out.print(a1);
  if(b==0 && a1<16)
  {
   System.out.print(0);
  }
  if(b>9)
  {
   c=(char)(b+55);
   System.out.print(c);
  }
  else
  {
   System.out.print(b);
  }
  return;
 }
}

1 comment:

  1. thanks..
    http://www.yuklex.blogspot.com

    ReplyDelete