title: Decimal to Hexadecimal Converter in Java
body: <p>I have a homework assignment where I need to do three-way conversion between decimal, binary and hexadecimal. The function I need help with is converting a decimal into a hexadecimal. I have nearly no understanding of hexadecimal, nonetheless how to convert a decimal into hex. I need a function that takes in an <code>int dec</code> and returns a <code>String hex</code>. Unfortunately I don't have any draft of this function, I'm completely lost. All I have is this.</p>
  
  <pre><code>  public static String decToHex(int dec)
    {
      String hex = "";
  
  
      return hex;
    }
  </code></pre>
  
  <p>Also I can't use those premade functions like Integer.toHexString() or anything, I need to actually make the algorithm or I wouldn't have learned anything.</p>