import java.util.Scanner; public class FindHexString { public static void main(String[] args) { String hexString = ""; //output a hex string int decNumber; //decimal number to be converted int storeInput; //copy f input decimal number int remainder; Scanner in = new Scanner(System.in); //read the decimal number to be converted System.out.println("Please enter a positive integer: "); decNumber = in.nextInt(); storeInput = decNumber; //remember input for late print //rejecting negative number input while(decNumber < 0 ){ System.out.println("Enter only positive integers please!"); decNumber = in.nextInt(); storeInput = decNumber; } if(decNumber == 0 ){ System.out.println("Input decimal number is: " + storeInput); System.out.println("Hexadecimal value is: 0"); return; } //conversion process while(decNumber > 0){ remainder = decNumber % 16; decNumber /= 16; hexString = remainder + hexString; } if(decNumber = 10){ //this is the part I'm having trouble with hexString = "A"; } System.out.println("Input decimal number is " + storeInput); System.out.println("Hexadecimal value = " + hexString); } }

I am trying to figure out how to convert from decimal to hexadecimal without using the java library function. This is just a guess. I could be wrong.

Please and thank you for your help.