Good Evening to all..
Can someone help with regards to converting decimal to hexadecimal?
I'm using stack.
I am done. in doing Dec to binary and Decimal to Octal.
My problem is how to convert decimal to hex? specially if its include now with letters A to D..

pls i really need ur answers or suggestions.. here is my code for converting dec to hex.

System.out.print("Enter a Decimal Value:");
                num=console.nextInt();
                 q=num;
                while(true)
           {
               s.push(q%16);
               q=q/16;
               
               if(q==0)
               break;
            }
            System.out.print("HexaDecimal equivalent");
            while(!s.isEmpty())
            {
                
             System.out.print(s.pop());
            }

my problem is that.. how about if the pop value is 10? basically it should be converted into letter A. but how to do that? pls me... i really need to finish my program.. :(

I assume you have an int in the range 0 -15, so the clean way to do it is to have an arrray of chars, initilised to '0' ... 'F' and use the int as an index into this array.

and then what will i do next?

What I described will convert your int to the corresponding char 0 - F.
What do you want to do with next?

sir, can you give me psuedocode for it pls? so that i can understand it very well

Just try it - you will learn a lot more that way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.