-6

I have the code to write a program that people enter a decimal value and i have to convert it to Hex, Octal, Binary, and Character values. Everything but Character value will print out in java eclipse. Simple program but confused.

Henso
  • 1
  • What code have you written so far? – Nayuki Oct 16 '15 at 14:28
  • 1
    Possible duplicate of [How to convert ASCII code (0-255) to a String of the associated character?](http://stackoverflow.com/questions/7693994/how-to-convert-ascii-code-0-255-to-a-string-of-the-associated-character) – Manos Nikolaidis Oct 16 '15 at 14:30
  • 2
    Confused with what? We're not mind readers. – Sterling Archer Oct 16 '15 at 14:31
  • You would start by doing some research on this topic. Do you really, seriously think that you are the very first person in the world who wants to do something like that? And that nobody else ever documented how to do such a thing? – GhostCat Oct 16 '15 at 14:34

2 Answers2

0

Try something like this:

int i=65;
System.out.println((char)i);
A. Sinha
  • 2,666
  • 3
  • 26
  • 45
0

Convert the integer to string, and take it digit by digit.

Then add 48 or (30 Hex) to each digit to get its ASCII code.

e.g. int(5) will be (5 + 48) = 53

e.g. int(16) will be (6 + 48) = 54, and (1 + 48) = 49

I hope this solves it.

0FiRE0
  • 146
  • 5