heres what i have but it wont paste the letters to the corresponding digit
public String Hex(int z)
{

num=z;
while(num>=1)
{
z = num % 16;
hex = z + hex;
num /= 16;

switch (z)
{
case 10: hex ="a";
break;
case 11: hex ="b";
break;
case 12: hex ="c";
break;
case 13: hex ="d";
break;
case 14: hex ="e";
break;
case 15: hex ="f";
break;
default: hex=hex;
break;

}
}

can anyone fix this code to do the conversion?

There's a built in method to do just that... Not going to tell you what it is as that would be too simple, just look in the API docs for the logical classes you'd expect to have such methods.