Write RecursiveBases with four recursive methods (no loops, no Integer.toBinaryString or parseInt with a base):
decToBin(int n)anddecToHex(int n)return aString;binToDec(String bits)andhexToDec(String hex)return anint.
Ideas: the binary form of n is the binary form of n / 2 followed by the bit n % 2; the value of a bit string is twice the value of all its bits but the last, plus the last bit.
main reads pairs dec 13, bin 1101 or hex 1F until the end of the input. For the input
dec 13
dec 255
dec 0
bin 1101
hex 1F
hex ff
dec 4096
the program prints
13 = 1101 in binary = D in hexadecimal
255 = 11111111 in binary = FF in hexadecimal
0 = 0 in binary = 0 in hexadecimal
1101 in binary = 13
1F in hexadecimal = 31
ff in hexadecimal = 255
4096 = 1000000000000 in binary = 1000 in hexadecimal