/**

* @(#)dayau_0.java

*

* dayau_0 application

*

* @author

* @version 1.00 2009/9/28

*/

public class dayau_0 {

public static void main(String[] args) {

int num = 30;

String AnsHex = "";

AnsHex = DectoHexDec(num);

System.out.println(AnsHex);

}

public static int DectoHexDec(int x) {

String result = "";

int remainder = 0;

while (x>0){

remainder = x%16;

switch(remainder){

case 1 : result = Integer.toString(remainder)+result;

break;

case 2 : result = Integer.toString(remainder)+result;

break;

case 3 : result = Integer.toString(remainder)+result;

break;

case 4 : result = Integer.toString(remainder)+result;

break;

case 5 : result = Integer.toString(remainder)+result;

break;

case 6 : result = Integer.toString(remainder)+result;

break;

case 7 : result = Integer.toString(remainder)+result;

break;

case 8 : result = Integer.toString(remainder)+result;

break;

case 9 : result = Integer.toString(remainder)+result;

break;

case 10 : result = "A"+result;

break;

case 11 : result = "B"+result;

break;

case 12 : result = "C"+result;

break;

case 13 : result = "D"+result;

break;

case 14 : result = "E"+result;

break;

case 15 : result = "F"+result;

break;

}

x = x/16;

}

return result;

}

}