Decimal conversion hexadecimal problem Description The hexadecimal number is a representation of an integer that is often used in programming. It has 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f a total of 16 symbols, representing 0 to 15 of the decimal number. The hexadecimal count method is 16 in 1, so the decimal number 16 in hexadecimal is 10, while the decimal 17 in hexadecimal is 11, and so on, the decimal 30 in hexadecimal is 1 E.
A nonnegative integer is given, which is represented as a 16-binary form. Input format input contains a non-negative integer A that represents the number to convert. 0<=a<=2147483647 output Format Output 16 binary representation of this integer example input 30 sample output 1E
Code:
Import Java.util.Scanner;
public class Main {public
static void Main (string[] args) throws Exception {
Scanner in = new Scanner (system.in);
Long a = In.nextlong ();
Char[] B = new char[10000001];
int i = 0;
if (a==0)
System.out.println (0);
while (A! = 0) {
int t = (int) (A%16);
If (a% >= 0 && a% <= 9) {
b[i++] = (char) (' 0 ' +t);
}
else {
if (a%16>=10&&a%16<=15)
b[i++]= (char) (' a ' +t-10);
}
a/=16;
}
for (int j = i-1; j>=0; j--)
System.out.print (B[j]);
}
}